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