browser/metro/base/tests/mochitest/browser_prompt.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/tests/mochitest/browser_prompt.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     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 +function test() {
    1.11 +  waitForExplicitFinish();
    1.12 +  runTests();
    1.13 +}
    1.14 +
    1.15 +gTests.push({
    1.16 +  desc: "Test getPrompt with null domWindow (bug 949333)",
    1.17 +  run: function () {
    1.18 +    let factory = Cc["@mozilla.org/prompter;1"].getService(Ci.nsIPromptFactory);
    1.19 +    let prompter = factory.getPrompt(null, Ci.nsIPrompt);
    1.20 +
    1.21 +    let browser = getBrowser();
    1.22 +    let dialogOpened = false;
    1.23 +
    1.24 +    Task.spawn(function() {
    1.25 +      yield waitForEvent(browser, "DOMWillOpenModalDialog");
    1.26 +      dialogOpened = true;
    1.27 +
    1.28 +      yield waitForMs(0);
    1.29 +      let stack = browser.parentNode;
    1.30 +      let dialogs = stack.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
    1.31 +      is(dialogs.length, 1, "one tab-modal dialog showing");
    1.32 +
    1.33 +      let dialog = dialogs[0];
    1.34 +      let okButton = dialog.ui.button0;
    1.35 +      okButton.click();
    1.36 +    });
    1.37 +
    1.38 +    prompter.alert("Test", "test");
    1.39 +
    1.40 +    ok(dialogOpened, "Dialog was opened");
    1.41 +  }
    1.42 +});

mercurial