Bug 1234936 - part 2: always focus tabs when they show an onbeforeunload dialog, r=billm
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4364,19 +4364,21 @@
let tabForEvent = targetIsWindow ?
this._getTabForContentWindow(event.target.top) :
this.getTabForBrowser(event.originalTarget);
// Don't need to act if the tab is already selected:
if (tabForEvent.selected)
return;
- // If this is a tabprompt, we won't switch tabs
- // (unless this behaviour has been disabled entirely using the pref)
+ // If this is a tabprompt, we won't switch tabs, unless:
+ // - this is a beforeunload prompt
+ // - this behaviour has been disabled entirely using the pref
if (event.detail && event.detail.tabPrompt &&
+ !event.detail.inPermitUnload &&
Services.prefs.getBoolPref("browser.tabs.dontfocusfordialogs")) {
let docPrincipal = targetIsWindow ? event.target.document.nodePrincipal : null;
// At least one of these should/will be non-null:
let promptPrincipal = event.detail.promptPrincipal || docPrincipal ||
tabForEvent.linkedBrowser.contentPrincipal;
// For null principals, we bail immediately and don't show the checkbox:
if (!promptPrincipal || promptPrincipal.isNullPrincipal) {
tabForEvent.setAttribute("attention", "true");
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -475,16 +475,17 @@ function openRemotePrompt(domWin, args,
domWin.removeEventListener("pagehide", pagehide);
messageManager.sendAsyncMessage("Prompt:ForceClose", { _remoteId: id });
}
let topPrincipal = domWin.top.document.nodePrincipal;
let promptPrincipal = domWin.document.nodePrincipal;
args.promptPrincipal = promptPrincipal;
args.showAlertOrigin = topPrincipal.equals(promptPrincipal);
+ args.inPermitUnload = inPermitUnload;
args._remoteId = id;
messageManager.sendAsyncMessage("Prompt:Open", args, {});
let thread = Services.tm.currentThread;
while (!closed) {
thread.processNextEvent(true);