browser/components/sessionstore/test/browser_477657.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:865d9e4c382f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 function test() {
6 /** Test for Bug 477657 **/
7 waitForExplicitFinish();
8
9 let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
10 newWin.addEventListener("load", function(aEvent) {
11 newWin.removeEventListener("load", arguments.callee, false);
12
13 let newState = { windows: [{
14 tabs: [{ entries: [] }],
15 _closedTabs: [{
16 state: { entries: [{ url: "about:" }]},
17 title: "About:"
18 }],
19 sizemode: "maximized"
20 }] };
21
22 let uniqueKey = "bug 477657";
23 let uniqueValue = "unik" + Date.now();
24
25 ss.setWindowValue(newWin, uniqueKey, uniqueValue);
26 is(ss.getWindowValue(newWin, uniqueKey), uniqueValue,
27 "window value was set before the window was overwritten");
28 ss.setWindowState(newWin, JSON.stringify(newState), true);
29
30 // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures
31 newWin.setTimeout(function() {
32 is(ss.getWindowValue(newWin, uniqueKey), "",
33 "window value was implicitly cleared");
34
35 is(newWin.windowState, newWin.STATE_MAXIMIZED,
36 "the window was maximized");
37
38 is(JSON.parse(ss.getClosedTabData(newWin)).length, 1,
39 "the closed tab was added before the window was overwritten");
40 delete newState.windows[0]._closedTabs;
41 delete newState.windows[0].sizemode;
42 ss.setWindowState(newWin, JSON.stringify(newState), true);
43
44 newWin.setTimeout(function() {
45 is(JSON.parse(ss.getClosedTabData(newWin)).length, 0,
46 "closed tabs were implicitly cleared");
47
48 is(newWin.windowState, newWin.STATE_MAXIMIZED,
49 "the window remains maximized");
50 newState.windows[0].sizemode = "normal";
51 ss.setWindowState(newWin, JSON.stringify(newState), true);
52
53 newWin.setTimeout(function() {
54 isnot(newWin.windowState, newWin.STATE_MAXIMIZED,
55 "the window was explicitly unmaximized");
56
57 newWin.close();
58 finish();
59 }, 0);
60 }, 0);
61 }, 0);
62 }, false);
63 }

mercurial