mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 05:39:41 +02:00
This converts the tabmodalprompt binding to a class, to be constructed along side with the element by TabModalPromptBox. TabModalPromptBox will keep the instances in a map and pass it to the callers, instead of the element. The tests and callers can access the class instance by passing the element reference to the map. Differential Revision: https://phabricator.services.mozilla.com/D15505 --HG-- rename : toolkit/components/prompts/content/tabprompts.xml => toolkit/components/prompts/content/tabprompts.jsm extra : moz-landing-system : lando
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
function whenBrowserLoaded(browser, callback) {
|
|
return BrowserTestUtils.browserLoaded(browser).then(callback);
|
|
}
|
|
|
|
function waitForOnBeforeUnloadDialog(browser, callback) {
|
|
browser.addEventListener("DOMWillOpenModalDialog", function onModalDialog(event) {
|
|
if (Cu.isCrossProcessWrapper(event.target)) {
|
|
// This event fires in both the content and chrome processes. We
|
|
// want to ignore the one in the content process.
|
|
return;
|
|
}
|
|
|
|
browser.removeEventListener("DOMWillOpenModalDialog", onModalDialog, true);
|
|
|
|
SimpleTest.waitForCondition(() => Services.focus.activeWindow == browser.ownerGlobal, function() {
|
|
let stack = browser.parentNode;
|
|
let dialogs = stack.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
|
|
let {button0, button1} = browser.tabModalPromptBox.prompts.get(dialogs[0]).ui;
|
|
callback(button0, button1);
|
|
}, "Waited too long for window with dialog to focus");
|
|
}, true);
|
|
}
|