browser/components/sessionstore/test/browser_477657.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 477657 **/
michael@0 7 waitForExplicitFinish();
michael@0 8
michael@0 9 let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
michael@0 10 newWin.addEventListener("load", function(aEvent) {
michael@0 11 newWin.removeEventListener("load", arguments.callee, false);
michael@0 12
michael@0 13 let newState = { windows: [{
michael@0 14 tabs: [{ entries: [] }],
michael@0 15 _closedTabs: [{
michael@0 16 state: { entries: [{ url: "about:" }]},
michael@0 17 title: "About:"
michael@0 18 }],
michael@0 19 sizemode: "maximized"
michael@0 20 }] };
michael@0 21
michael@0 22 let uniqueKey = "bug 477657";
michael@0 23 let uniqueValue = "unik" + Date.now();
michael@0 24
michael@0 25 ss.setWindowValue(newWin, uniqueKey, uniqueValue);
michael@0 26 is(ss.getWindowValue(newWin, uniqueKey), uniqueValue,
michael@0 27 "window value was set before the window was overwritten");
michael@0 28 ss.setWindowState(newWin, JSON.stringify(newState), true);
michael@0 29
michael@0 30 // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures
michael@0 31 newWin.setTimeout(function() {
michael@0 32 is(ss.getWindowValue(newWin, uniqueKey), "",
michael@0 33 "window value was implicitly cleared");
michael@0 34
michael@0 35 is(newWin.windowState, newWin.STATE_MAXIMIZED,
michael@0 36 "the window was maximized");
michael@0 37
michael@0 38 is(JSON.parse(ss.getClosedTabData(newWin)).length, 1,
michael@0 39 "the closed tab was added before the window was overwritten");
michael@0 40 delete newState.windows[0]._closedTabs;
michael@0 41 delete newState.windows[0].sizemode;
michael@0 42 ss.setWindowState(newWin, JSON.stringify(newState), true);
michael@0 43
michael@0 44 newWin.setTimeout(function() {
michael@0 45 is(JSON.parse(ss.getClosedTabData(newWin)).length, 0,
michael@0 46 "closed tabs were implicitly cleared");
michael@0 47
michael@0 48 is(newWin.windowState, newWin.STATE_MAXIMIZED,
michael@0 49 "the window remains maximized");
michael@0 50 newState.windows[0].sizemode = "normal";
michael@0 51 ss.setWindowState(newWin, JSON.stringify(newState), true);
michael@0 52
michael@0 53 newWin.setTimeout(function() {
michael@0 54 isnot(newWin.windowState, newWin.STATE_MAXIMIZED,
michael@0 55 "the window was explicitly unmaximized");
michael@0 56
michael@0 57 newWin.close();
michael@0 58 finish();
michael@0 59 }, 0);
michael@0 60 }, 0);
michael@0 61 }, 0);
michael@0 62 }, false);
michael@0 63 }

mercurial