browser/components/sessionstore/test/browser_465223.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 function test() {
michael@0 6 /** Test for Bug 465223 **/
michael@0 7
michael@0 8 // test setup
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 let uniqueKey1 = "bug 465223.1";
michael@0 12 let uniqueKey2 = "bug 465223.2";
michael@0 13 let uniqueValue1 = "unik" + Date.now();
michael@0 14 let uniqueValue2 = "pi != " + Math.random();
michael@0 15
michael@0 16 // open a window and set a value on it
michael@0 17 let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
michael@0 18 newWin.addEventListener("load", function(aEvent) {
michael@0 19 newWin.removeEventListener("load", arguments.callee, false);
michael@0 20
michael@0 21 ss.setWindowValue(newWin, uniqueKey1, uniqueValue1);
michael@0 22
michael@0 23 let newState = { windows: [{ tabs:[{ entries: [] }], extData: {} }] };
michael@0 24 newState.windows[0].extData[uniqueKey2] = uniqueValue2;
michael@0 25 ss.setWindowState(newWin, JSON.stringify(newState), false);
michael@0 26
michael@0 27 is(newWin.gBrowser.tabs.length, 2,
michael@0 28 "original tab wasn't overwritten");
michael@0 29 is(ss.getWindowValue(newWin, uniqueKey1), uniqueValue1,
michael@0 30 "window value wasn't overwritten when the tabs weren't");
michael@0 31 is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue2,
michael@0 32 "new window value was correctly added");
michael@0 33
michael@0 34 newState.windows[0].extData[uniqueKey2] = uniqueValue1;
michael@0 35 ss.setWindowState(newWin, JSON.stringify(newState), true);
michael@0 36
michael@0 37 is(newWin.gBrowser.tabs.length, 1,
michael@0 38 "original tabs were overwritten");
michael@0 39 is(ss.getWindowValue(newWin, uniqueKey1), "",
michael@0 40 "window value was cleared");
michael@0 41 is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue1,
michael@0 42 "window value was correctly overwritten");
michael@0 43
michael@0 44 // clean up
michael@0 45 newWin.close();
michael@0 46 finish();
michael@0 47 }, false);
michael@0 48 }

mercurial