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 465223 **/ michael@0: michael@0: // test setup michael@0: waitForExplicitFinish(); michael@0: michael@0: let uniqueKey1 = "bug 465223.1"; michael@0: let uniqueKey2 = "bug 465223.2"; michael@0: let uniqueValue1 = "unik" + Date.now(); michael@0: let uniqueValue2 = "pi != " + Math.random(); michael@0: michael@0: // open a window and set a value on it 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: ss.setWindowValue(newWin, uniqueKey1, uniqueValue1); michael@0: michael@0: let newState = { windows: [{ tabs:[{ entries: [] }], extData: {} }] }; michael@0: newState.windows[0].extData[uniqueKey2] = uniqueValue2; michael@0: ss.setWindowState(newWin, JSON.stringify(newState), false); michael@0: michael@0: is(newWin.gBrowser.tabs.length, 2, michael@0: "original tab wasn't overwritten"); michael@0: is(ss.getWindowValue(newWin, uniqueKey1), uniqueValue1, michael@0: "window value wasn't overwritten when the tabs weren't"); michael@0: is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue2, michael@0: "new window value was correctly added"); michael@0: michael@0: newState.windows[0].extData[uniqueKey2] = uniqueValue1; michael@0: ss.setWindowState(newWin, JSON.stringify(newState), true); michael@0: michael@0: is(newWin.gBrowser.tabs.length, 1, michael@0: "original tabs were overwritten"); michael@0: is(ss.getWindowValue(newWin, uniqueKey1), "", michael@0: "window value was cleared"); michael@0: is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue1, michael@0: "window value was correctly overwritten"); michael@0: michael@0: // clean up michael@0: newWin.close(); michael@0: finish(); michael@0: }, false); michael@0: }