Path: blob/trunk/javascript/webdriver/atoms/storage/session_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 Utility functions for accessing HTML5 sessionStorage object.19* These functions are wrapper of the functions of individual method of20* bot.storage.Storage class. An extra redirection is used to define21* individual functional unit (atom) for injecting in Webdriver.22*/2324goog.provide('webdriver.atoms.storage.session');2526goog.require('bot.storage');272829/**30* Utility function to set the value of a key/value pair in sessionStorage.31* @param {string} key The key of the item.32* @param {*} value The value of the item.33*/34webdriver.atoms.storage.session.setItem = function(key, value) {35bot.storage.getSessionStorage().setItem(key, value);36};373839/**40* Returns the value item of a key in the sessionStorage object.41* @param {string} key The key of the returned value.42* @return {?string} The mapped value if present in the sessionStorage object,43* otherwise null.44*/45webdriver.atoms.storage.session.getItem = function(key) {46return bot.storage.getSessionStorage().getItem(key);47};484950/**51* Returns an array of keys of all keys of the sessionStorage object.52* @return {Array.<string>} The array of stored keys..53*/54webdriver.atoms.storage.session.keySet = function() {55return bot.storage.getSessionStorage().keySet();56};575859/**60* Removes an item with a given key.61* @param {string} key The key of the key/value pair.62* @return {?string} The removed value if present, otherwise null.63*/64webdriver.atoms.storage.session.removeItem = function(key) {65return bot.storage.getSessionStorage().removeItem(key);66};676869/**70* Removes all items from the sessionStorage object.71*/72webdriver.atoms.storage.session.clear = function() {73bot.storage.getSessionStorage().clear();74};757677/**78* Returns the number of items in the sessionStorage object.79* @return {number} The number of the key/value pairs.80*/81webdriver.atoms.storage.session.size = function() {82return bot.storage.getSessionStorage().size();83};848586/**87* Returns the key item of the key/value pairs in the sessionStorage object88* of a given index.89* @param {number} index The index of the key/value pair list.90* @return {?string} The key item of a given index.91*/92webdriver.atoms.storage.session.key = function(index) {93return bot.storage.getSessionStorage().key(index);94};95969798