michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: /** Test for Bug 477657 **/ michael@0: waitForExplicitFinish(); michael@0: michael@0: let newWin = openDialog(location, "_blank", "chrome,all,dialog=no"); michael@0: newWin.addEventListener("load", function(aEvent) { michael@0: newWin.removeEventListener("load", arguments.callee, false); michael@0: michael@0: let newState = { windows: [{ michael@0: tabs: [{ entries: [] }], michael@0: _closedTabs: [{ michael@0: state: { entries: [{ url: "about:" }]}, michael@0: title: "About:" michael@0: }], michael@0: sizemode: "maximized" michael@0: }] }; michael@0: michael@0: let uniqueKey = "bug 477657"; michael@0: let uniqueValue = "unik" + Date.now(); michael@0: michael@0: ss.setWindowValue(newWin, uniqueKey, uniqueValue); michael@0: is(ss.getWindowValue(newWin, uniqueKey), uniqueValue, michael@0: "window value was set before the window was overwritten"); michael@0: ss.setWindowState(newWin, JSON.stringify(newState), true); michael@0: michael@0: // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures michael@0: newWin.setTimeout(function() { michael@0: is(ss.getWindowValue(newWin, uniqueKey), "", michael@0: "window value was implicitly cleared"); michael@0: michael@0: is(newWin.windowState, newWin.STATE_MAXIMIZED, michael@0: "the window was maximized"); michael@0: michael@0: is(JSON.parse(ss.getClosedTabData(newWin)).length, 1, michael@0: "the closed tab was added before the window was overwritten"); michael@0: delete newState.windows[0]._closedTabs; michael@0: delete newState.windows[0].sizemode; michael@0: ss.setWindowState(newWin, JSON.stringify(newState), true); michael@0: michael@0: newWin.setTimeout(function() { michael@0: is(JSON.parse(ss.getClosedTabData(newWin)).length, 0, michael@0: "closed tabs were implicitly cleared"); michael@0: michael@0: is(newWin.windowState, newWin.STATE_MAXIMIZED, michael@0: "the window remains maximized"); michael@0: newState.windows[0].sizemode = "normal"; michael@0: ss.setWindowState(newWin, JSON.stringify(newState), true); michael@0: michael@0: newWin.setTimeout(function() { michael@0: isnot(newWin.windowState, newWin.STATE_MAXIMIZED, michael@0: "the window was explicitly unmaximized"); michael@0: michael@0: newWin.close(); michael@0: finish(); michael@0: }, 0); michael@0: }, 0); michael@0: }, 0); michael@0: }, false); michael@0: }