|
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 const URIS_PINNED = ["about:license", "about:about"]; |
|
6 const URIS_NORMAL_A = ["about:mozilla"]; |
|
7 const URIS_NORMAL_B = ["about:buildconfig"]; |
|
8 |
|
9 function test() { |
|
10 waitForExplicitFinish(); |
|
11 |
|
12 isnot(Services.prefs.getIntPref("browser.startup.page"), 3, |
|
13 "pref to save session must not be set for this test"); |
|
14 ok(!Services.prefs.getBoolPref("browser.sessionstore.resume_session_once"), |
|
15 "pref to save session once must not be set for this test"); |
|
16 |
|
17 document.documentElement.setAttribute("windowtype", "navigator:browsertestdummy"); |
|
18 |
|
19 openWinWithCb(closeFirstWin, URIS_PINNED.concat(URIS_NORMAL_A)); |
|
20 } |
|
21 |
|
22 function closeFirstWin(win) { |
|
23 win.gBrowser.pinTab(win.gBrowser.tabs[0]); |
|
24 win.gBrowser.pinTab(win.gBrowser.tabs[1]); |
|
25 win.BrowserTryToCloseWindow(); |
|
26 ok(win.closed, "window closed"); |
|
27 |
|
28 openWinWithCb(checkSecondWin, URIS_NORMAL_B, URIS_PINNED.concat(URIS_NORMAL_B)); |
|
29 } |
|
30 |
|
31 function checkSecondWin(win) { |
|
32 is(win.gBrowser.browsers[0].currentURI.spec, URIS_PINNED[0], "first pinned tab restored"); |
|
33 is(win.gBrowser.browsers[1].currentURI.spec, URIS_PINNED[1], "second pinned tab restored"); |
|
34 ok(win.gBrowser.tabs[0].pinned, "first pinned tab is still pinned"); |
|
35 ok(win.gBrowser.tabs[1].pinned, "second pinned tab is still pinned"); |
|
36 win.close(); |
|
37 |
|
38 // cleanup |
|
39 document.documentElement.setAttribute("windowtype", "navigator:browser"); |
|
40 finish(); |
|
41 } |
|
42 |
|
43 function openWinWithCb(cb, argURIs, expectedURIs) { |
|
44 if (!expectedURIs) |
|
45 expectedURIs = argURIs; |
|
46 |
|
47 var win = openDialog(getBrowserURL(), "_blank", |
|
48 "chrome,all,dialog=no", argURIs.join("|")); |
|
49 |
|
50 win.addEventListener("load", function () { |
|
51 win.removeEventListener("load", arguments.callee, false); |
|
52 info("the window loaded"); |
|
53 |
|
54 var expectedLoads = expectedURIs.length; |
|
55 |
|
56 win.gBrowser.addTabsProgressListener({ |
|
57 onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { |
|
58 if (aRequest && |
|
59 aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && |
|
60 aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK && |
|
61 expectedURIs.indexOf(aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec) > -1 && |
|
62 --expectedLoads <= 0) { |
|
63 win.gBrowser.removeTabsProgressListener(this); |
|
64 info("all tabs loaded"); |
|
65 is(win.gBrowser.tabs.length, expectedURIs.length, "didn't load any unexpected tabs"); |
|
66 executeSoon(function () { |
|
67 cb(win); |
|
68 }); |
|
69 } |
|
70 } |
|
71 }); |
|
72 }, false); |
|
73 } |