From 8d9dc9efac8939d5de665066375b1139ba5e9cb1 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Tue, 29 Sep 2015 15:46:23 -0700 Subject: [PATCH] Bug 967873 - Allow RemotePrompt to be closed while it's being opened (r=Gijs) --- browser/modules/RemotePrompt.jsm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/browser/modules/RemotePrompt.jsm b/browser/modules/RemotePrompt.jsm index 1e142be2dab..041b8a3effc 100644 --- a/browser/modules/RemotePrompt.jsm +++ b/browser/modules/RemotePrompt.jsm @@ -39,11 +39,18 @@ var RemotePrompt = { let tabPrompt = window.gBrowser.getTabModalPromptBox(browser) let callbackInvoked = false; let newPrompt; + let needRemove = false; let promptId = args._remoteId; function onPromptClose(forceCleanup) { + // It's possible that we removed the prompt during the + // appendPrompt call below. In that case, newPrompt will be + // undefined. We set the needRemove flag to remember to remove + // it right after we've finished adding it. if (newPrompt) tabPrompt.removePrompt(newPrompt); + else + needRemove = true; PromptUtils.fireDialogEvent(window, "DOMModalDialogClosed", browser); browser.messageManager.sendAsyncMessage("Prompt:Close", args); @@ -69,6 +76,10 @@ var RemotePrompt = { newPrompt = tabPrompt.appendPrompt(args, onPromptClose); + if (needRemove) { + tabPrompt.removePrompt(newPrompt); + } + // TODO since we don't actually open a window, need to check if // there's other stuff in nsWindowWatcher::OpenWindowInternal // that we might need to do here as well.