toolkit/components/startup/tests/browser/browser_bug537449.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/startup/tests/browser/browser_bug537449.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +const TEST_URL = "http://example.com/browser/toolkit/components/startup/tests/browser/beforeunload.html";
    1.11 +
    1.12 +function test() {
    1.13 +  waitForExplicitFinish();
    1.14 +
    1.15 +  gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
    1.16 +  let browser = gBrowser.selectedBrowser;
    1.17 +
    1.18 +  whenBrowserLoaded(browser, function () {
    1.19 +    let seenDialog = false;
    1.20 +
    1.21 +    // Cancel the prompt the first time.
    1.22 +    waitForOnBeforeUnloadDialog(browser, (btnLeave, btnStay) => {
    1.23 +      seenDialog = true;
    1.24 +      btnStay.click();
    1.25 +    });
    1.26 +
    1.27 +    let appStartup = Cc['@mozilla.org/toolkit/app-startup;1'].
    1.28 +                       getService(Ci.nsIAppStartup);
    1.29 +    appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
    1.30 +    ok(seenDialog, "Should have seen a prompt dialog");
    1.31 +    ok(!window.closed, "Shouldn't have closed the window");
    1.32 +
    1.33 +    let win2 = window.openDialog(location, "", "chrome,all,dialog=no", "about:blank");
    1.34 +    ok(win2 != null, "Should have been able to open a new window");
    1.35 +    win2.addEventListener("load", function onLoad() {
    1.36 +      win2.removeEventListener("load", onLoad);
    1.37 +      win2.close();
    1.38 +
    1.39 +      // Leave the page the second time.
    1.40 +      waitForOnBeforeUnloadDialog(browser, (btnLeave, btnStay) => {
    1.41 +        btnLeave.click();
    1.42 +      });
    1.43 +
    1.44 +      gBrowser.removeTab(gBrowser.selectedTab);
    1.45 +      executeSoon(finish);
    1.46 +    });
    1.47 +  });
    1.48 +}

mercurial