Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/webdriver/atoms/inject/local_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 Ready to inject atoms for handling local storage.
20
*/
21
22
goog.provide('webdriver.atoms.inject.storage.local');
23
24
goog.require('webdriver.atoms.inject');
25
goog.require('webdriver.atoms.storage.local');
26
27
28
/**
29
* Sets an item in the local storage.
30
*
31
* @param {string} key The key of the item.
32
* @param {*} value The value of the item.
33
* @return {string} The stringified result wrapped according to the wire
34
* protocol.
35
*/
36
webdriver.atoms.inject.storage.local.setItem = function(key, value) {
37
return webdriver.atoms.inject.executeScript(
38
webdriver.atoms.storage.local.setItem, [key, value]);
39
};
40
41
42
/**
43
* Gets an item from the local storage.
44
*
45
* @param {string} key The key of the item.
46
* @return {string} The stringified result wrapped according to the wire
47
* protocol.
48
*/
49
webdriver.atoms.inject.storage.local.getItem = function(key) {
50
return webdriver.atoms.inject.executeScript(
51
webdriver.atoms.storage.local.getItem, [key]);
52
};
53
54
55
/**
56
* Gets the key set of the entries.
57
*
58
* @return {string} The stringified result wrapped according to the wire
59
* protocol.
60
*/
61
webdriver.atoms.inject.storage.local.keySet = function() {
62
return webdriver.atoms.inject.executeScript(
63
webdriver.atoms.storage.local.keySet, []);
64
};
65
66
67
/**
68
* Removes an item in the local storage.
69
*
70
* @param {string} key The key of the item.
71
* @return {string} The stringified result wrapped according to the wire
72
* protocol.
73
*/
74
webdriver.atoms.inject.storage.local.removeItem = function(key) {
75
return webdriver.atoms.inject.executeScript(
76
webdriver.atoms.storage.local.removeItem, [key]);
77
};
78
79
80
/**
81
* Clears the local storage.
82
*
83
* @return {string} The stringified result wrapped according to the wire
84
* protocol.
85
*/
86
webdriver.atoms.inject.storage.local.clear = function() {
87
return webdriver.atoms.inject.executeScript(
88
webdriver.atoms.storage.local.clear, []);
89
};
90
91
92
/**
93
* Gets the size of the local storage.
94
*
95
* @return {string} The stringified result wrapped according to the wire
96
* protocol.
97
*/
98
webdriver.atoms.inject.storage.local.size = function() {
99
return webdriver.atoms.inject.executeScript(
100
webdriver.atoms.storage.local.size, []);
101
};
102
103