browser/components/sessionstore/test/browser_global_store.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:71ac8f0999c2
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // Tests the API for saving global session data.
5 function runTests() {
6 const key1 = "Unique name 1: " + Date.now();
7 const key2 = "Unique name 2: " + Date.now();
8 const value1 = "Unique value 1: " + Math.random();
9 const value2 = "Unique value 2: " + Math.random();
10
11 let global = {};
12 global[key1] = value1;
13
14 const testState = {
15 windows: [
16 {
17 tabs: [
18 { entries: [{ url: "about:blank" }] },
19 ]
20 }
21 ],
22 global: global
23 };
24
25 function testRestoredState() {
26 is(ss.getGlobalValue(key1), value1, "restored state has global value");
27 }
28
29 function testGlobalStore() {
30 is(ss.getGlobalValue(key2), "", "global value initially not set");
31
32 ss.setGlobalValue(key2, value1);
33 is(ss.getGlobalValue(key2), value1, "retreived value matches stored");
34
35 ss.setGlobalValue(key2, value2);
36 is(ss.getGlobalValue(key2), value2, "previously stored value was overwritten");
37
38 ss.deleteGlobalValue(key2);
39 is(ss.getGlobalValue(key2), "", "global value was deleted");
40 }
41
42 yield waitForBrowserState(testState, next);
43 testRestoredState();
44 testGlobalStore();
45 }
46
47 function test() {
48 TestRunner.run();
49 }

mercurial