michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests the API for saving global session data. michael@0: function runTests() { michael@0: const key1 = "Unique name 1: " + Date.now(); michael@0: const key2 = "Unique name 2: " + Date.now(); michael@0: const value1 = "Unique value 1: " + Math.random(); michael@0: const value2 = "Unique value 2: " + Math.random(); michael@0: michael@0: let global = {}; michael@0: global[key1] = value1; michael@0: michael@0: const testState = { michael@0: windows: [ michael@0: { michael@0: tabs: [ michael@0: { entries: [{ url: "about:blank" }] }, michael@0: ] michael@0: } michael@0: ], michael@0: global: global michael@0: }; michael@0: michael@0: function testRestoredState() { michael@0: is(ss.getGlobalValue(key1), value1, "restored state has global value"); michael@0: } michael@0: michael@0: function testGlobalStore() { michael@0: is(ss.getGlobalValue(key2), "", "global value initially not set"); michael@0: michael@0: ss.setGlobalValue(key2, value1); michael@0: is(ss.getGlobalValue(key2), value1, "retreived value matches stored"); michael@0: michael@0: ss.setGlobalValue(key2, value2); michael@0: is(ss.getGlobalValue(key2), value2, "previously stored value was overwritten"); michael@0: michael@0: ss.deleteGlobalValue(key2); michael@0: is(ss.getGlobalValue(key2), "", "global value was deleted"); michael@0: } michael@0: michael@0: yield waitForBrowserState(testState, next); michael@0: testRestoredState(); michael@0: testGlobalStore(); michael@0: } michael@0: michael@0: function test() { michael@0: TestRunner.run(); michael@0: }