Bug 949333 - Make Metro prompt service work for Master Password [r=TimAbraldes]

This commit is contained in:
Matt Brubeck 2013-12-16 10:15:09 -08:00
parent cac9aae55a
commit a7c639ddf0
3 changed files with 50 additions and 10 deletions

View File

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function test() {
waitForExplicitFinish();
runTests();
}
gTests.push({
desc: "Test getPrompt with null domWindow (bug 949333)",
run: function () {
let factory = Cc["@mozilla.org/prompter;1"].getService(Ci.nsIPromptFactory);
let prompter = factory.getPrompt(null, Ci.nsIPrompt);
let browser = getBrowser();
let dialogOpened = false;
Task.spawn(function() {
yield waitForEvent(browser, "DOMWillOpenModalDialog");
dialogOpened = true;
yield waitForMs(0);
let stack = browser.parentNode;
let dialogs = stack.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
is(dialogs.length, 1, "one tab-modal dialog showing");
let dialog = dialogs[0];
let okButton = dialog.ui.button0;
okButton.click();
});
prompter.alert("Test", "test");
ok(dialogOpened, "Dialog was opened");
}
});

View File

@ -47,6 +47,7 @@ support-files =
[browser_link_click.js]
[browser_onscreen_keyboard.js]
[browser_prefs_ui.js]
[browser_prompt.js]
[browser_remotetabs.js]
[browser_snappedState.js]
[browser_tabs.js]

View File

@ -22,6 +22,16 @@ PromptService.prototype = {
/* ---------- nsIPromptFactory ---------- */
getPrompt: function getPrompt(domWin, iid) {
if (!domWin) {
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
if (!chromeWin) {
let msg = "PromptService.js: Attempted create a prompt but no DOM Window specified and failed to find one";
Cu.reportError(msg);
throw(msg);
}
domWin = chromeWin.getBrowser().contentWindow;
}
let factory =
Components.classesByID["{1c978d25-b37f-43a8-a2d6-0c7a239ead87}"]
.createInstance(Ci.nsIPromptFactory);
@ -39,16 +49,6 @@ PromptService.prototype = {
callProxy: function(aName, aArgs) {
let domWin = aArgs[0];
if (!domWin) {
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
if (!chromeWin) {
let msg = "PromptService.js: Attempted create a prompt but no DOM Window specified and failed to find one";
Cu.reportError(msg);
throw(msg);
}
domWin = chromeWin.getBrowser().contentWindow;
}
let prompt = this.getPrompt(domWin, Ci.nsIPrompt);
if (aName == 'promptAuth' || aName == 'promptAuthAsync') {
let adapterFactory =