Path: blob/trunk/javascript/webdriver/atoms/inject/local_storage.js
2868 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617/**18* @fileoverview Ready to inject atoms for handling local storage.19*/2021goog.provide('webdriver.atoms.inject.storage.local');2223goog.require('webdriver.atoms.inject');24goog.require('webdriver.atoms.storage.local');252627/**28* Sets an item in the local storage.29*30* @param {string} key The key of the item.31* @param {*} value The value of the item.32* @return {string} The stringified result wrapped according to the wire33* protocol.34*/35webdriver.atoms.inject.storage.local.setItem = function(key, value) {36return webdriver.atoms.inject.executeScript(37webdriver.atoms.storage.local.setItem, [key, value]);38};394041/**42* Gets an item from the local storage.43*44* @param {string} key The key of the item.45* @return {string} The stringified result wrapped according to the wire46* protocol.47*/48webdriver.atoms.inject.storage.local.getItem = function(key) {49return webdriver.atoms.inject.executeScript(50webdriver.atoms.storage.local.getItem, [key]);51};525354/**55* Gets the key set of the entries.56*57* @return {string} The stringified result wrapped according to the wire58* protocol.59*/60webdriver.atoms.inject.storage.local.keySet = function() {61return webdriver.atoms.inject.executeScript(62webdriver.atoms.storage.local.keySet, []);63};646566/**67* Removes an item in the local storage.68*69* @param {string} key The key of the item.70* @return {string} The stringified result wrapped according to the wire71* protocol.72*/73webdriver.atoms.inject.storage.local.removeItem = function(key) {74return webdriver.atoms.inject.executeScript(75webdriver.atoms.storage.local.removeItem, [key]);76};777879/**80* Clears the local storage.81*82* @return {string} The stringified result wrapped according to the wire83* protocol.84*/85webdriver.atoms.inject.storage.local.clear = function() {86return webdriver.atoms.inject.executeScript(87webdriver.atoms.storage.local.clear, []);88};899091/**92* Gets the size of the local storage.93*94* @return {string} The stringified result wrapped according to the wire95* protocol.96*/97webdriver.atoms.inject.storage.local.size = function() {98return webdriver.atoms.inject.executeScript(99webdriver.atoms.storage.local.size, []);100};101102103