|
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 465223 **/ |
|
7 |
|
8 // test setup |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 let uniqueKey1 = "bug 465223.1"; |
|
12 let uniqueKey2 = "bug 465223.2"; |
|
13 let uniqueValue1 = "unik" + Date.now(); |
|
14 let uniqueValue2 = "pi != " + Math.random(); |
|
15 |
|
16 // open a window and set a value on it |
|
17 let newWin = openDialog(location, "_blank", "chrome,all,dialog=no"); |
|
18 newWin.addEventListener("load", function(aEvent) { |
|
19 newWin.removeEventListener("load", arguments.callee, false); |
|
20 |
|
21 ss.setWindowValue(newWin, uniqueKey1, uniqueValue1); |
|
22 |
|
23 let newState = { windows: [{ tabs:[{ entries: [] }], extData: {} }] }; |
|
24 newState.windows[0].extData[uniqueKey2] = uniqueValue2; |
|
25 ss.setWindowState(newWin, JSON.stringify(newState), false); |
|
26 |
|
27 is(newWin.gBrowser.tabs.length, 2, |
|
28 "original tab wasn't overwritten"); |
|
29 is(ss.getWindowValue(newWin, uniqueKey1), uniqueValue1, |
|
30 "window value wasn't overwritten when the tabs weren't"); |
|
31 is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue2, |
|
32 "new window value was correctly added"); |
|
33 |
|
34 newState.windows[0].extData[uniqueKey2] = uniqueValue1; |
|
35 ss.setWindowState(newWin, JSON.stringify(newState), true); |
|
36 |
|
37 is(newWin.gBrowser.tabs.length, 1, |
|
38 "original tabs were overwritten"); |
|
39 is(ss.getWindowValue(newWin, uniqueKey1), "", |
|
40 "window value was cleared"); |
|
41 is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue1, |
|
42 "window value was correctly overwritten"); |
|
43 |
|
44 // clean up |
|
45 newWin.close(); |
|
46 finish(); |
|
47 }, false); |
|
48 } |