Bug 1539757 - fix trying to initialize XBL bindings while the prompt is still hidden, r=bgrins

Differential Revision: https://phabricator.services.mozilla.com/D25390

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-03-29 23:11:37 +00:00
Родитель f7a8b4c054
Коммит 4ffc2ff028
4 изменённых файлов: 21 добавлений и 14 удалений

Просмотреть файл

@ -8369,6 +8369,8 @@ TabModalPromptBox.prototype = {
if (prompts.length) {
let prompt = prompts[prompts.length - 1];
prompt.element.hidden = false;
// Because we were hidden before, this won't have been possible, so do it now:
prompt.ensureXBLBindingAttached();
prompt.Dialog.setDefaultFocus();
} else {
browser.removeAttribute("tabmodalPromptShowing");

Просмотреть файл

@ -8,20 +8,21 @@
* the oldest one.
*/
add_task(async function() {
const PROMPTCOUNT = 5;
const PROMPTCOUNT = 9;
let contentScript = function() {
var i = 5; // contentScript has no access to PROMPTCOUNT.
let contentScript = function(MAX_PROMPT) {
var i = MAX_PROMPT;
let fns = ["alert", "prompt", "confirm"];
window.addEventListener("message", function() {
i--;
if (i) {
window.postMessage("ping", "*");
}
alert("Alert countdown #" + i);
window[fns[i % 3]](fns[i % 3] + " countdown #" + i);
});
window.postMessage("ping", "*");
};
let url = "data:text/html,<script>(" + encodeURIComponent(contentScript.toSource()) + ")();</script>";
let url = "data:text/html,<script>(" + encodeURIComponent(contentScript.toSource()) + ")(" + PROMPTCOUNT + ");</script>";
let promptsOpenedPromise = new Promise(function(resolve) {
let unopenedPromptCount = PROMPTCOUNT;
@ -48,7 +49,8 @@ add_task(async function() {
let i = 0;
for (let promptElement of promptElements) {
let prompt = tab.linkedBrowser.tabModalPromptBox.prompts.get(promptElement);
is(prompt.Dialog.args.text, "Alert countdown #" + i, "The #" + i + " alert should be labelled as such.");
let expectedType = ["alert", "prompt", "confirm"][i % 3];
is(prompt.Dialog.args.text, expectedType + " countdown #" + i, "The #" + i + " alert should be labelled as such.");
if (i !== promptElementsCount) {
is(prompt.element.hidden, true, "This prompt should be hidden.");
i++;

Просмотреть файл

@ -80,6 +80,7 @@ var RemotePrompt = {
// there's other stuff in nsWindowWatcher::OpenWindowInternal
// that we might need to do here as well.
} catch (ex) {
Cu.reportError(ex);
onPromptClose(true);
}
},

Просмотреть файл

@ -162,6 +162,7 @@ CommonDialog.prototype = {
else
button.setAttribute("default", "true");
if (!this.ui.promptContainer.hidden) {
// For tab prompts, we will need to ensure its content bindings are attached.
if (!xulDialog) {
this.ui.prompt.ensureXBLBindingAttached();
@ -169,6 +170,7 @@ CommonDialog.prototype = {
// Set default focus / selection.
this.setDefaultFocus(true);
}
if (this.args.enableDelay) {
this.delayHelper = new EnableDelayHelper({