browser/components/sessionstore/test/browser_580512.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial