Backed out 3 changesets (bug 1685313) for failing test_prompt.html on a CLOSED TREE

Backed out changeset 7bdcbdc2d57f (bug 1685313)
Backed out changeset 319bc4d7bc0d (bug 1685313)
Backed out changeset 713de42fe3b4 (bug 1685313)
This commit is contained in:
Andreea Pavel 2021-02-12 06:50:58 +02:00
parent ad194164f5
commit c9c6e3158d
19 changed files with 124 additions and 418 deletions

View File

@ -1370,15 +1370,6 @@ pref("prompts.tabChromePromptSubDialog", true);
pref("prompts.contentPromptSubDialog", false);
#endif
// Whether to show window-modal dialogs opened for browser windows
// in a SubDialog inside their parent, instead of an OS level window.
#ifdef NIGHTLY_BUILD
pref("prompts.windowPromptSubDialog", true);
#else
pref("prompts.windowPromptSubDialog", false);
#endif
// Activates preloading of the new tab url.
pref("browser.newtab.preload", true);

View File

@ -206,11 +206,13 @@
<menuitem id="enterFullScreenItem"
key="key_fullScreen" data-l10n-id="menu-view-enter-full-screen">
<observes element="View:FullScreen" attribute="oncommand"/>
<observes element="View:FullScreen" attribute="disabled"/>
</menuitem>
<menuitem id="exitFullScreenItem"
key="key_fullScreen"
hidden="true" data-l10n-id="menu-view-exit-full-screen">
<observes element="View:FullScreen" attribute="oncommand"/>
<observes element="View:FullScreen" attribute="disabled"/>
</menuitem>
#else
<menuitem id="fullScreenItem"

View File

@ -1479,7 +1479,7 @@ toolbar[keyNav=true]:not([collapsed=true], [customizing=true]) toolbartabstop {
}
/**
* Dialogs
* Tab Dialogs
*/
.dialogStack {
@ -1572,21 +1572,6 @@ toolbar[keyNav=true]:not([collapsed=true], [customizing=true]) toolbartabstop {
place-content: center;
}
/* Override default <html:dialog> styles */
#window-modal-dialog {
border-width: 0;
background-color: transparent;
}
#window-modal-dialog::backdrop {
background-color: rgba(0, 0, 0, 0.5);
}
/* Hide tab-modal dialogs when a window-modal one is up. */
:root[window-modal-open] .browserStack > .dialogStack {
visibility: hidden;
}
/**
* End Dialogs
* End Tab Dialogs
*/

View File

@ -71,7 +71,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
SimpleServiceDiscovery: "resource://gre/modules/SimpleServiceDiscovery.jsm",
SiteDataManager: "resource:///modules/SiteDataManager.jsm",
SitePermissions: "resource:///modules/SitePermissions.jsm",
SubDialog: "resource://gre/modules/SubDialog.jsm",
SubDialogManager: "resource://gre/modules/SubDialog.jsm",
TabModalPrompt: "chrome://global/content/tabprompts.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
@ -9302,144 +9301,6 @@ TabModalPromptBox.prototype = {
},
};
// Handle window-modal prompts that we want to display with the same style as
// tab-modal prompts.
var gDialogBox = {
_dialog: null,
get isOpen() {
return !!this._dialog;
},
async open(uri, args) {
try {
await this._open(uri, args);
} catch (ex) {
Cu.reportError(ex);
} finally {
let dialog = document.getElementById("window-modal-dialog");
dialog.close();
dialog.style.visibility = "hidden";
dialog.style.height = "0";
dialog.style.width = "0";
document.documentElement.removeAttribute("window-modal-open");
dialog.removeEventListener("dialogopen", this);
this._updateMenuAndCommandState(true /* to enable */);
this._dialog = null;
}
return args;
},
handleEvent(event) {
if (event.type == "dialogopen") {
this._dialog.focus(true);
}
},
_open(uri, args) {
// Get this offset before we touch style below, as touching style seems
// to reset the cached layout bounds.
let offset = window.windowUtils.getBoundsWithoutFlushing(
gBrowser.selectedBrowser
).top;
let parentElement = document.getElementById("window-modal-dialog");
// The dialog has 1em padding; compensate for that:
parentElement.style.marginTop = `calc(${offset}px - 1em)`;
parentElement.style.removeProperty("visibility");
parentElement.style.removeProperty("width");
parentElement.style.removeProperty("height");
document.documentElement.setAttribute("window-modal-open", true);
// Call this first so the contents show up and get layout, which is
// required for SubDialog to work.
parentElement.showModal();
// Disable menus and shortcuts.
this._updateMenuAndCommandState(false /* to disable */);
// Now actually set up the dialog contents:
let template = document.getElementById("window-modal-dialog-template")
.content.firstElementChild;
parentElement.addEventListener("dialogopen", this);
this._dialog = new SubDialog({
template,
parentElement,
id: "window-modal-dialog-subdialog",
options: {
consumeOutsideClicks: false,
},
});
let closedPromise = new Promise(resolve => {
this._closedCallback = resolve;
});
this._dialog.open(
uri,
{
features: "resizable=no",
modalType: Ci.nsIPrompt.MODAL_TYPE_INTERNAL_WINDOW,
closedCallback: () => {
this._closedCallback();
},
},
args
);
return closedPromise;
},
_nonUpdatableElements: new Set([
// Make an exception for debugging tools, for developer ease of use.
"key_browserConsole",
"key_browserToolbox",
// Don't touch the editing keys/commands which we might want inside the dialog.
"key_undo",
"key_redo",
"key_cut",
"key_copy",
"key_paste",
"key_delete",
"key_selectAll",
]),
_updateMenuAndCommandState(shouldBeEnabled) {
let editorCommands = document.getElementById("editMenuCommands");
// For the following items, set or clear disabled state:
// - toplevel menubar items (will affect inner items on macOS)
// - command elements
// - key elements not connected to command elements.
for (let element of document.querySelectorAll(
"menubar > menu, command, key:not([command])"
)) {
if (
editorCommands?.contains(element) ||
(element.id && this._nonUpdatableElements.has(element.id))
) {
continue;
}
if (element.nodeName == "key" && element.command) {
continue;
}
if (!shouldBeEnabled) {
if (element.getAttribute("disabled") != "true") {
element.setAttribute("disabled", true);
} else {
element.setAttribute("wasdisabled", true);
}
} else if (element.getAttribute("wasdisabled") != "true") {
element.removeAttribute("disabled");
} else {
element.removeAttribute("wasdisabled");
}
}
},
};
// browser.js loads in the library window, too, but we can only show prompts
// in the main browser window:
if (window.location.href != AppConstants.BROWSER_CHROME_URL) {
gDialogBox = null;
}
var ConfirmationHint = {
_timerID: null,

View File

@ -1618,17 +1618,6 @@
</panelview>
</html:template>
<html:dialog id="window-modal-dialog" style="visibility: hidden; height: 0; width: 0"/>
<html:template id="window-modal-dialog-template">
<vbox class="dialogTemplate dialogOverlay" align="center" topmost="true">
<hbox class="dialogBox">
<browser class="dialogFrame"
autoscroll="false"
disablehistory="true"/>
</hbox>
</vbox>
</html:template>
<!-- Temporary wrapper until we move away from XUL flex to allow a negative
margin-top to slide the toolbox off screen in fullscreen layout.-->
<box>

View File

@ -41,7 +41,6 @@ function nonBrowserWindowStartup() {
"charsetMenu",
"View:PageSource",
"View:FullScreen",
"enterFullScreenItem",
"viewHistorySidebar",
"Browser:AddBookmarkAs",
"Browser:BookmarkAllTabs",

View File

@ -290,7 +290,6 @@
set selectedTab(val) {
if (
gSharedTabWarning.willShowSharedTabWarning(val) ||
document.documentElement.hasAttribute("window-modal-open") ||
(gNavToolbox.collapsed && !this._allowTabChange)
) {
return;

View File

@ -20,13 +20,7 @@ add_task(async function() {
ok(homeButton, "home button present");
async function drop(dragData, homepage) {
let setHomepageDialogPromise = BrowserTestUtils.promiseAlertDialogOpen(
"accept"
);
let setHomepagePromise = TestUtils.waitForPrefChange(
HOMEPAGE_PREF,
newVal => newVal == homepage
);
let setHomepageDialogPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
EventUtils.synthesizeDrop(
dragSrcElement,
@ -35,18 +29,33 @@ add_task(async function() {
"copy",
window
);
// Ensure dnd suppression is cleared.
EventUtils.synthesizeMouseAtCenter(homeButton, { type: "mouseup" }, window);
await setHomepageDialogPromise;
let setHomepageDialog = await setHomepageDialogPromise;
ok(true, "dialog appeared in response to home button drop");
await setHomepagePromise;
let setHomepagePromise = new Promise(function(resolve) {
let observer = {
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
observe(subject, topic, data) {
is(topic, "nsPref:changed", "observed correct topic");
is(data, HOMEPAGE_PREF, "observed correct data");
let modified = Services.prefs.getStringPref(HOMEPAGE_PREF);
is(modified, homepage, "homepage is set correctly");
Services.prefs.removeObserver(HOMEPAGE_PREF, observer);
let modified = Services.prefs.getStringPref(HOMEPAGE_PREF);
is(modified, homepage, "homepage is set correctly");
Services.prefs.setStringPref(HOMEPAGE_PREF, "about:mozilla;");
Services.prefs.setStringPref(HOMEPAGE_PREF, "about:mozilla;");
resolve();
},
};
Services.prefs.addObserver(HOMEPAGE_PREF, observer);
});
setHomepageDialog.document.getElementById("commonDialog").acceptDialog();
await setHomepagePromise;
}
function dropInvalidURI() {

View File

@ -7,4 +7,3 @@ skip-if = verify && debug && (os == 'linux')
[browser_openPromptInBackgroundTab.js]
support-files = openPromptOffTimeout.html
[browser_promptFocus.js]
[browser_windowPrompt.js]

View File

@ -1,66 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that the in-window modal dialogs work correctly.
*/
add_task(async function test_check_window_modal_prompt_service() {
await SpecialPowers.pushPrefEnv({
set: [["prompts.windowPromptSubDialog", true]],
});
let dialogPromise = BrowserTestUtils.promiseAlertDialogOpen(null);
// Avoid blocking the test on the (sync) alert by sticking it in a timeout:
setTimeout(
() => Services.prompt.alert(window, "Some title", "some message"),
0
);
let dialogWin = await dialogPromise;
// Check dialog content:
is(
dialogWin.document.getElementById("infoTitle").textContent,
"Some title",
"Title should be correct."
);
is(
dialogWin.document.getElementById("infoBody").textContent,
"some message",
"Body text should be correct."
);
// Check circumstances of opening.
ok(
dialogWin?.docShell?.chromeEventHandler,
"Should have embedded the dialog."
);
is(
window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
"none",
"Browser window should be inert."
);
for (let menu of document.querySelectorAll("menubar > menu")) {
ok(menu.disabled, `Menu ${menu.id} should be disabled.`);
}
let container = dialogWin.docShell.chromeEventHandler.closest("dialog");
let closedPromise = BrowserTestUtils.waitForMutationCondition(
container,
{ childList: true, attributes: true },
() => !container.hasChildNodes() && !container.open
);
EventUtils.sendKey("ESCAPE");
await closedPromise;
// Check we cleaned up:
is(
window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
"auto",
"Browser window should no longer be inert."
);
for (let menu of document.querySelectorAll("menubar > menu")) {
ok(!menu.disabled, `Menu ${menu.id} should not be disabled anymore.`);
}
});

View File

@ -8,9 +8,8 @@
registerCleanupFunction(() => {});
async function assertDialogResult({ args, buttonToClick, expectedResult }) {
let promise = BrowserTestUtils.promiseAlertDialog(buttonToClick);
BrowserTestUtils.promiseAlertDialogOpen(buttonToClick);
is(await DownloadsCommon.confirmUnblockDownload(args), expectedResult);
await promise;
}
/**

View File

@ -153,7 +153,7 @@ add_task(async function() {
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
// Test clearing service worker through the settings panel
// Test clearing service wroker through the settings panel
add_task(async function() {
// Register a test service worker
await loadServiceWorkerTestPage(TEST_SERVICE_WORKER_URL);

View File

@ -23,10 +23,10 @@ add_task(async function refresh() {
"Restore default settings and remove old add-ons for optimal performance.",
button: /^Refresh .+…$/,
awaitCallback() {
return BrowserTestUtils.promiseAlertDialog(
"cancel",
"chrome://global/content/resetProfile.xhtml"
);
return promiseAlertDialog("cancel", [
"chrome://global/content/resetProfile.xhtml",
"chrome://global/content/resetProfile.xul",
]);
},
});
});
@ -41,10 +41,10 @@ add_task(async function clear() {
title: "Clear your cache, cookies, history and more.",
button: "Choose What to Clear…",
awaitCallback() {
return BrowserTestUtils.promiseAlertDialog(
"cancel",
"chrome://browser/content/sanitize.xhtml"
);
return promiseAlertDialog("cancel", [
"chrome://browser/content/sanitize.xhtml",
"chrome://browser/content/sanitize.xul",
]);
},
});
});

View File

@ -519,6 +519,52 @@ async function awaitNoTip(searchString, win = window) {
}
}
/**
* Copied from BrowserTestUtils.jsm, but lets you listen for any one of multiple
* dialog URIs instead of only one.
* @param {string} buttonAction
* What button should be pressed on the alert dialog.
* @param {array} uris
* The URIs for the alert dialogs.
* @param {function} [func]
* An optional callback.
*/
async function promiseAlertDialogOpen(buttonAction, uris, func) {
let win = await BrowserTestUtils.domWindowOpened(null, async aWindow => {
// The test listens for the "load" event which guarantees that the alert
// class has already been added (it is added when "DOMContentLoaded" is
// fired).
await BrowserTestUtils.waitForEvent(aWindow, "load");
return uris.includes(aWindow.document.documentURI);
});
if (func) {
await func(win);
return win;
}
let dialog = win.document.querySelector("dialog");
dialog.getButton(buttonAction).click();
return win;
}
/**
* Copied from BrowserTestUtils.jsm, but lets you listen for any one of multiple
* dialog URIs instead of only one.
* @param {string} buttonAction
* What button should be pressed on the alert dialog.
* @param {array} uris
* The URIs for the alert dialogs.
* @param {function} [func]
* An optional callback.
*/
async function promiseAlertDialog(buttonAction, uris, func) {
let win = await promiseAlertDialogOpen(buttonAction, uris, func);
return BrowserTestUtils.windowClosed(win);
}
/**
* Search tips helper. Asserts that a particular search tip is shown or that no
* search tip is shown.

View File

@ -66,9 +66,6 @@ interface nsIPrompt : nsISupports
const unsigned long MODAL_TYPE_CONTENT = 1;
const unsigned long MODAL_TYPE_TAB = 2;
const unsigned long MODAL_TYPE_WINDOW = 3;
// Like MODAL_TYPE_WINDOW, but shown inside a parent window (with similar
// styles as _TAB and _CONTENT types) rather than as a new window:
const unsigned long MODAL_TYPE_INTERNAL_WINDOW = 4;
int32_t confirmEx(in wstring dialogTitle,
in wstring text,

View File

@ -1393,32 +1393,6 @@ var BrowserTestUtils = {
}
},
/**
* Wait until DOM mutations cause the condition expressed in checkFn
* to pass.
*
* Intended as an easy-to-use alternative to waitForCondition.
*
* @param {Element} target The target in which to observe mutations.
* @param {Object} options The options to pass to MutationObserver.observe();
* @param {function} checkFn Function that returns true when it wants the promise to be
* resolved.
*/
waitForMutationCondition(target, options, checkFn) {
if (checkFn()) {
return Promise.resolve();
}
return new Promise(resolve => {
let obs = new target.ownerGlobal.MutationObserver(function() {
if (checkFn()) {
obs.disconnect();
resolve();
}
});
obs.observe(target, options);
});
},
/**
* Like browserLoaded, but waits for an error page to appear.
*
@ -2260,29 +2234,24 @@ var BrowserTestUtils = {
async promiseAlertDialogOpen(
buttonAction,
uri = "chrome://global/content/commonDialog.xhtml",
func = null
func
) {
let win;
if (uri == "chrome://global/content/commonDialog.xhtml") {
[win] = await TestUtils.topicObserved("common-dialog-loaded");
} else {
let win = await this.domWindowOpened(null, async win => {
// The test listens for the "load" event which guarantees that the alert
// class has already been added (it is added when "DOMContentLoaded" is
// fired).
win = await this.domWindowOpenedAndLoaded(null, async win => {
return win.document.documentURI === uri;
});
}
await this.waitForEvent(win, "load");
return win.document.documentURI === uri;
});
if (func) {
await func(win);
return win;
}
if (buttonAction) {
let dialog = win.document.querySelector("dialog");
dialog.getButton(buttonAction).click();
}
let dialog = win.document.querySelector("dialog");
dialog.getButton(buttonAction).click();
return win;
},
@ -2306,15 +2275,7 @@ var BrowserTestUtils = {
func
) {
let win = await this.promiseAlertDialogOpen(buttonAction, uri, func);
if (!win.docShell.browsingContext.embedderElement) {
return this.windowClosed(win);
}
let container = win.top.document.getElementById("window-modal-dialog");
return this.waitForMutationCondition(
container,
{ childList: true, attributes: true },
() => !container.hasChildNodes() && !container.open
);
return this.windowClosed(win);
},
/**

View File

@ -13,16 +13,6 @@ var { PromptUtils } = ChromeUtils.import(
"resource://gre/modules/SharedPromptUtils.jsm"
);
const {
// MODAL_TYPE_TAB, // currently not read in this file.
MODAL_TYPE_CONTENT,
MODAL_TYPE_WINDOW,
MODAL_TYPE_INTERNAL_WINDOW,
} = Ci.nsIPrompt;
const COMMON_DIALOG = "chrome://global/content/commonDialog.xhtml";
const SELECT_DIALOG = "chrome://global/content/selectDialog.xhtml";
function Prompter() {
// Note that EmbedPrompter clones this implementation.
}
@ -977,14 +967,6 @@ class ModalPrompter {
this.browsingContext = browsingContext;
}
if (
domWin &&
(!modalType || modalType == MODAL_TYPE_WINDOW) &&
!this.browsingContext?.isContent
) {
modalType = MODAL_TYPE_INTERNAL_WINDOW;
}
// Use given modal type or fallback to default
this.modalType = modalType || ModalPrompter.defaultModalType;
@ -1000,42 +982,19 @@ class ModalPrompter {
set modalType(modalType) {
// Setting modal type window is always allowed
if (modalType == MODAL_TYPE_WINDOW) {
if (modalType == Ci.nsIPrompt.MODAL_TYPE_WINDOW) {
this._modalType = modalType;
return;
}
// For content prompts for non-content windows, use window prompts:
if (modalType == MODAL_TYPE_CONTENT && !this.browsingContext?.isContent) {
this._modalType = MODAL_TYPE_WINDOW;
return;
}
// We can't use content / tab prompts if we don't have a suitable parent.
if (
!this.browsingContext?.isContent &&
modalType != MODAL_TYPE_INTERNAL_WINDOW
) {
// Only show this error if we're not about to fall back again and show a different one.
if (this.browsingContext?.associatedWindow?.gDialogBox) {
Cu.reportError(
"Prompter: Browser not available. Falling back to internal window prompt."
);
}
modalType = MODAL_TYPE_INTERNAL_WINDOW;
}
if (!this.browsingContext?.isContent) {
modalType = Ci.nsIPrompt.MODAL_TYPE_WINDOW;
if (
modalType == MODAL_TYPE_INTERNAL_WINDOW &&
(this.browsingContext?.isContent ||
!this.browsingContext?.associatedWindow?.gDialogBox)
) {
Cu.reportError(
"Prompter: internal dialogs not available in this context. Falling back to window prompt."
"Prompter: Browser not available. Falling back to window prompt."
);
modalType = MODAL_TYPE_WINDOW;
}
this._modalType = modalType;
}
@ -1072,22 +1031,17 @@ class ModalPrompter {
return args;
}
if (this._modalType == MODAL_TYPE_INTERNAL_WINDOW) {
await this.openInternalWindowPrompt(
this.browsingContext.associatedWindow,
args
);
return args;
}
// Select prompts are not part of CommonDialog
// and thus not supported as tab or content prompts yet. See Bug 1622817.
// Once they are integrated this override should be removed.
if (args.promptType == "select" && this.modalType !== MODAL_TYPE_WINDOW) {
if (
args.promptType == "select" &&
this.modalType !== Ci.nsIPrompt.MODAL_TYPE_WINDOW
) {
Cu.reportError(
"Prompter: 'select' prompts do not support tab/content prompting. Falling back to window prompt."
);
args.modalType = MODAL_TYPE_WINDOW;
args.modalType = Ci.nsIPrompt.MODAL_TYPE_WINDOW;
} else {
args.modalType = this.modalType;
}
@ -1128,7 +1082,7 @@ class ModalPrompter {
args.inPermitUnload = inPermitUnload;
let eventDetail = Cu.cloneInto(
{
tabPrompt: this.modalType != MODAL_TYPE_WINDOW,
tabPrompt: this.modalType != Ci.nsIPrompt.MODAL_TYPE_WINDOW,
inPermitUnload,
},
this.browsingContext.window
@ -1210,6 +1164,9 @@ class ModalPrompter {
* @param {Object} args - Prompt options and return values.
*/
openWindowPrompt(parentWindow = null, args) {
const COMMON_DIALOG = "chrome://global/content/commonDialog.xhtml";
const SELECT_DIALOG = "chrome://global/content/selectDialog.xhtml";
let uri = args.promptType == "select" ? SELECT_DIALOG : COMMON_DIALOG;
let propBag = PromptUtils.objectToPropBag(args);
Services.ww.openWindow(
@ -1222,17 +1179,6 @@ class ModalPrompter {
PromptUtils.propBagToObject(propBag, args);
}
async openInternalWindowPrompt(parentWindow, args) {
if (!parentWindow?.gDialogBox || !ModalPrompter.windowPromptSubDialog) {
this.openWindowPrompt(parentWindow, args);
return;
}
let propBag = PromptUtils.objectToPropBag(args);
let uri = args.promptType == "select" ? SELECT_DIALOG : COMMON_DIALOG;
await parentWindow.gDialogBox.open(uri, propBag);
PromptUtils.propBagToObject(propBag, args);
}
/**
* Calls async prompt method and optionally runs promise chained task on
* result data. Converts result data to nsIPropertyBag.
@ -1725,14 +1671,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
ModalPrompter,
"defaultModalType",
"prompts.defaultModalType",
MODAL_TYPE_WINDOW
);
XPCOMUtils.defineLazyPreferenceGetter(
ModalPrompter,
"windowPromptSubDialog",
"prompts.windowPromptSubDialog",
false
Ci.nsIPrompt.MODAL_TYPE_WINDOW
);
function AuthPromptAdapterFactory() {}

View File

@ -29,8 +29,8 @@ registerCleanupFunction(function() {
}
});
// NB: not using BrowserTestUtils.promiseAlertDialog here because there's no way to
// undo waiting for a dialog. If we don't want the window to be opened, and
// NB: not using BrowserTestUtils.domWindowOpened here because there's no way to
// undo waiting for a window open. If we don't want the window to be opened, and
// wait for it to verify that it indeed does not open, we need to be able to
// then "stop" waiting so that when we next *do* want it to open, our "old"
// listener doesn't fire and do things we don't want (like close the window...).
@ -38,15 +38,20 @@ let gCaretPromptOpeningObserver;
function promiseCaretPromptOpened() {
return new Promise(resolve => {
function observer(subject, topic, data) {
info("Dialog opened.");
resolve(subject);
gCaretPromptOpeningObserver();
if (topic == "domwindowopened") {
Services.ww.unregisterNotification(observer);
let win = subject;
BrowserTestUtils.waitForEvent(
win,
"load",
false,
e => e.target.location.href != "about:blank"
).then(() => resolve(win));
gCaretPromptOpeningObserver = null;
}
}
Services.obs.addObserver(observer, "common-dialog-loaded");
gCaretPromptOpeningObserver = () => {
Services.obs.removeObserver(observer, "common-dialog-loaded");
gCaretPromptOpeningObserver = () => {};
};
Services.ww.registerNotification(observer);
gCaretPromptOpeningObserver = observer;
});
}
@ -77,7 +82,8 @@ function syncToggleCaretNoDialog(expected) {
// Need to clean up if the dialog wasn't opened, so the observer doesn't get
// re-triggered later on causing "issues".
if (!openedDialog) {
gCaretPromptOpeningObserver();
Services.ww.unregisterNotification(gCaretPromptOpeningObserver);
gCaretPromptOpeningObserver = null;
}
let prefVal = Services.prefs.getBoolPref(kPrefCaretBrowsingOn);
is(prefVal, expected, "Caret browsing should now be " + expectedStr);

View File

@ -264,12 +264,7 @@
// give focus to the first focusable element in the dialog
let focusedElt = document.commandDispatcher.focusedElement;
if (!focusedElt) {
Services.focus.moveFocus(
window,
null,
Services.focus.MOVEFOCUS_FORWARD,
Services.focus.FLAG_NOPARENTFRAME
);
document.commandDispatcher.advanceFocusIntoSubtree(this);
focusedElt = document.commandDispatcher.focusedElement;
if (focusedElt) {
@ -278,12 +273,7 @@
focusedElt.localName == "tab" ||
focusedElt.getAttribute("noinitialfocus") == "true"
) {
Services.focus.moveFocus(
window,
focusedElt,
Services.focus.MOVEFOCUS_FORWARD,
Services.focus.FLAG_NOPARENTFRAME
);
document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
focusedElt = document.commandDispatcher.focusedElement;
if (focusedElt) {
if (focusedElt == initialFocusedElt) {