Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/webdriver/atoms/storage/session_storage.js
2868 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
/**
19
* @fileoverview Utility functions for accessing HTML5 sessionStorage object.
20
* These functions are wrapper of the functions of individual method of
21
* bot.storage.Storage class. An extra redirection is used to define
22
* individual functional unit (atom) for injecting in Webdriver.
23
*/
24
25
goog.provide('webdriver.atoms.storage.session');
26
27
goog.require('bot.storage');
28
29
30
/**
31
* Utility function to set the value of a key/value pair in sessionStorage.
32
* @param {string} key The key of the item.
33
* @param {*} value The value of the item.
34
*/
35
webdriver.atoms.storage.session.setItem = function(key, value) {
36
bot.storage.getSessionStorage().setItem(key, value);
37
};
38
39
40
/**
41
* Returns the value item of a key in the sessionStorage object.
42
* @param {string} key The key of the returned value.
43
* @return {?string} The mapped value if present in the sessionStorage object,
44
* otherwise null.
45
*/
46
webdriver.atoms.storage.session.getItem = function(key) {
47
return bot.storage.getSessionStorage().getItem(key);
48
};
49
50
51
/**
52
* Returns an array of keys of all keys of the sessionStorage object.
53
* @return {Array.<string>} The array of stored keys..
54
*/
55
webdriver.atoms.storage.session.keySet = function() {
56
return bot.storage.getSessionStorage().keySet();
57
};
58
59
60
/**
61
* Removes an item with a given key.
62
* @param {string} key The key of the key/value pair.
63
* @return {?string} The removed value if present, otherwise null.
64
*/
65
webdriver.atoms.storage.session.removeItem = function(key) {
66
return bot.storage.getSessionStorage().removeItem(key);
67
};
68
69
70
/**
71
* Removes all items from the sessionStorage object.
72
*/
73
webdriver.atoms.storage.session.clear = function() {
74
bot.storage.getSessionStorage().clear();
75
};
76
77
78
/**
79
* Returns the number of items in the sessionStorage object.
80
* @return {number} The number of the key/value pairs.
81
*/
82
webdriver.atoms.storage.session.size = function() {
83
return bot.storage.getSessionStorage().size();
84
};
85
86
87
/**
88
* Returns the key item of the key/value pairs in the sessionStorage object
89
* of a given index.
90
* @param {number} index The index of the key/value pair list.
91
* @return {?string} The key item of a given index.
92
*/
93
webdriver.atoms.storage.session.key = function(index) {
94
return bot.storage.getSessionStorage().key(index);
95
};
96
97
98