1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_477657.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + /** Test for Bug 477657 **/ 1.10 + waitForExplicitFinish(); 1.11 + 1.12 + let newWin = openDialog(location, "_blank", "chrome,all,dialog=no"); 1.13 + newWin.addEventListener("load", function(aEvent) { 1.14 + newWin.removeEventListener("load", arguments.callee, false); 1.15 + 1.16 + let newState = { windows: [{ 1.17 + tabs: [{ entries: [] }], 1.18 + _closedTabs: [{ 1.19 + state: { entries: [{ url: "about:" }]}, 1.20 + title: "About:" 1.21 + }], 1.22 + sizemode: "maximized" 1.23 + }] }; 1.24 + 1.25 + let uniqueKey = "bug 477657"; 1.26 + let uniqueValue = "unik" + Date.now(); 1.27 + 1.28 + ss.setWindowValue(newWin, uniqueKey, uniqueValue); 1.29 + is(ss.getWindowValue(newWin, uniqueKey), uniqueValue, 1.30 + "window value was set before the window was overwritten"); 1.31 + ss.setWindowState(newWin, JSON.stringify(newState), true); 1.32 + 1.33 + // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures 1.34 + newWin.setTimeout(function() { 1.35 + is(ss.getWindowValue(newWin, uniqueKey), "", 1.36 + "window value was implicitly cleared"); 1.37 + 1.38 + is(newWin.windowState, newWin.STATE_MAXIMIZED, 1.39 + "the window was maximized"); 1.40 + 1.41 + is(JSON.parse(ss.getClosedTabData(newWin)).length, 1, 1.42 + "the closed tab was added before the window was overwritten"); 1.43 + delete newState.windows[0]._closedTabs; 1.44 + delete newState.windows[0].sizemode; 1.45 + ss.setWindowState(newWin, JSON.stringify(newState), true); 1.46 + 1.47 + newWin.setTimeout(function() { 1.48 + is(JSON.parse(ss.getClosedTabData(newWin)).length, 0, 1.49 + "closed tabs were implicitly cleared"); 1.50 + 1.51 + is(newWin.windowState, newWin.STATE_MAXIMIZED, 1.52 + "the window remains maximized"); 1.53 + newState.windows[0].sizemode = "normal"; 1.54 + ss.setWindowState(newWin, JSON.stringify(newState), true); 1.55 + 1.56 + newWin.setTimeout(function() { 1.57 + isnot(newWin.windowState, newWin.STATE_MAXIMIZED, 1.58 + "the window was explicitly unmaximized"); 1.59 + 1.60 + newWin.close(); 1.61 + finish(); 1.62 + }, 0); 1.63 + }, 0); 1.64 + }, 0); 1.65 + }, false); 1.66 +}