Backed out 3 changesets (bug 1680637, bug 1682395) for browser/base/content/* failures CLOSED TREE

Backed out changeset 270e2e3183de (bug 1682395)
Backed out changeset e3566f596187 (bug 1680637)
Backed out changeset 66563136c84e (bug 1680637)
This commit is contained in:
Bogdan Tara 2021-01-11 21:36:20 +02:00
Родитель 37b2661e41
Коммит 6101a13054
17 изменённых файлов: 52 добавлений и 186 удалений

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

@ -29,13 +29,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
false false
); );
XPCOMUtils.defineLazyPreferenceGetter(
this,
"contentPromptSubDialog",
"prompts.contentPromptSubDialog",
false
);
/** /**
* @typedef {Object} Prompt * @typedef {Object} Prompt
* @property {Function} resolver * @property {Function} resolver
@ -125,14 +118,13 @@ class PromptParent extends JSWindowActorParent {
switch (message.name) { switch (message.name) {
case "Prompt:Open": { case "Prompt:Open": {
if ( if (
(args.modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT && args.modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT ||
!contentPromptSubDialog) ||
(args.modalType === Ci.nsIPrompt.MODAL_TYPE_TAB && (args.modalType === Ci.nsIPrompt.MODAL_TYPE_TAB &&
!tabChromePromptSubDialog) !tabChromePromptSubDialog)
) { ) {
return this.openContentPrompt(args, id); return this.openContentPrompt(args, id);
} }
return this.openPromptWithTabDialogBox(args); return this.openChromePrompt(args);
} }
} }
@ -233,19 +225,18 @@ class PromptParent extends JSWindowActorParent {
} }
/** /**
* Opens either a window prompt or TabDialogBox at the content or tab level * Opens a window prompt for a BrowsingContext, and puts the associated
* for a BrowsingContext, and puts the associated browser in the modal state * browser in the modal state until the prompt is closed.
* until the prompt is closed.
* *
* @param {Object} args * @param {Object} args
* The arguments passed up from the BrowsingContext to be passed * The arguments passed up from the BrowsingContext to be passed
* directly to the modal prompt. * directly to the modal window.
* @return {Promise} * @return {Promise}
* Resolves when the modal prompt is dismissed. * Resolves when the window prompt is dismissed.
* @resolves {Object} * @resolves {Object}
* The arguments returned from the modal prompt. * The arguments returned from the window prompt.
*/ */
async openPromptWithTabDialogBox(args) { async openChromePrompt(args) {
const COMMON_DIALOG = "chrome://global/content/commonDialog.xhtml"; const COMMON_DIALOG = "chrome://global/content/commonDialog.xhtml";
const SELECT_DIALOG = "chrome://global/content/selectDialog.xhtml"; const SELECT_DIALOG = "chrome://global/content/selectDialog.xhtml";
let uri = args.promptType == "select" ? SELECT_DIALOG : COMMON_DIALOG; let uri = args.promptType == "select" ? SELECT_DIALOG : COMMON_DIALOG;
@ -280,29 +271,15 @@ class PromptParent extends JSWindowActorParent {
let bag = PromptUtils.objectToPropBag(args); let bag = PromptUtils.objectToPropBag(args);
if ( if (args.modalType === Services.prompt.MODAL_TYPE_TAB) {
args.modalType === Services.prompt.MODAL_TYPE_TAB ||
args.modalType === Services.prompt.MODAL_TYPE_CONTENT
) {
if (!browser) { if (!browser) {
let modal_type = throw new Error("Cannot tab-prompt without a browser!");
args.modalType === Services.prompt.MODAL_TYPE_TAB
? "tab"
: "content";
throw new Error(`Cannot ${modal_type}-prompt without a browser!`);
} }
// Tab or content level prompt // Tab
let dialogBox = win.gBrowser.getTabDialogBox(browser); let dialogBox = win.gBrowser.getTabDialogBox(browser);
await dialogBox.open( await dialogBox.open(uri, { features: "resizable=no" }, bag);
uri,
{
features: "resizable=no",
modalType: args.modalType,
},
bag
);
} else { } else {
// Window prompt // Window
Services.ww.openWindow( Services.ww.openWindow(
win, win,
uri, uri,

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

@ -1353,14 +1353,6 @@ pref("browser.partnerlink.campaign.topsites", "amzn_2020_a1");
// TabModalPromptBox (false). // TabModalPromptBox (false).
pref("prompts.tabChromePromptSubDialog", true); pref("prompts.tabChromePromptSubDialog", true);
// Whether to show the dialogs opened at the content level, such as
// alert() or prompt(), using a SubDialogManager in the TabDialogBox.
#ifdef EARLY_BETA_OR_EARLIER
pref("prompts.contentPromptSubDialog", true);
#else
pref("prompts.contentPromptSubDialog", false);
#endif
// Activates preloading of the new tab url. // Activates preloading of the new tab url.
pref("browser.newtab.preload", true); pref("browser.newtab.preload", true);

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

@ -1568,11 +1568,6 @@ toolbar[keyNav=true]:not([collapsed=true], [customizing=true]) toolbartabstop {
width: 66ch; width: 66ch;
} }
.content-prompt-dialog > .dialogOverlay {
display: grid;
place-content: center;
}
/** /**
* End Tab Dialogs * End Tab Dialogs
*/ */

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

@ -8894,10 +8894,9 @@ const SafeBrowsingNotificationBox = {
}; };
/** /**
* The TabDialogBox supports opening window dialogs as SubDialogs on the tab and content * The TabDialogBox supports opening window dialogs as SubDialogs on tab level.
* level. Both tab and content dialogs have their own separate managers.
* Dialogs will be queued FIFO and cover the web content. * Dialogs will be queued FIFO and cover the web content.
* Dialogs are closed when the user reloads or leaves the page. * Tab dialogs are closed when the user reloads or leaves the page.
* While a dialog is open PopupNotifications, such as permission prompts, are * While a dialog is open PopupNotifications, such as permission prompts, are
* suppressed. * suppressed.
*/ */
@ -8905,11 +8904,9 @@ class TabDialogBox {
constructor(browser) { constructor(browser) {
this._weakBrowserRef = Cu.getWeakReference(browser); this._weakBrowserRef = Cu.getWeakReference(browser);
// Create parent element for tab dialogs // Create parent element for dialogs
let template = document.getElementById("dialogStackTemplate"); let template = document.getElementById("dialogStackTemplate");
let dialogStack = template.content.cloneNode(true).firstElementChild; let dialogStack = template.content.cloneNode(true).firstElementChild;
dialogStack.classList.add("tab-prompt-dialog");
this.browser.parentNode.insertBefore( this.browser.parentNode.insertBefore(
dialogStack, dialogStack,
this.browser.nextElementSibling this.browser.nextElementSibling
@ -8918,8 +8915,7 @@ class TabDialogBox {
// Initially the stack only contains the template // Initially the stack only contains the template
let dialogTemplate = dialogStack.firstElementChild; let dialogTemplate = dialogStack.firstElementChild;
// Create dialog manager for prompts at the tab level. this._dialogManager = new SubDialogManager({
this._tabDialogManager = new SubDialogManager({
dialogStack, dialogStack,
dialogTemplate, dialogTemplate,
orderType: SubDialogManager.ORDER_QUEUE, orderType: SubDialogManager.ORDER_QUEUE,
@ -8931,7 +8927,7 @@ class TabDialogBox {
} }
/** /**
* Open a dialog on tab or content level. * Open a dialog on tab level.
* @param {String} aURL - URL of the dialog to load in the tab box. * @param {String} aURL - URL of the dialog to load in the tab box.
* @param {Object} [aOptions] * @param {Object} [aOptions]
* @param {String} [aOptions.features] - Comma separated list of window * @param {String} [aOptions.features] - Comma separated list of window
@ -8944,8 +8940,6 @@ class TabDialogBox {
* @param {Boolean} [aOptions.keepOpenSameOriginNav] - By default dialogs are * @param {Boolean} [aOptions.keepOpenSameOriginNav] - By default dialogs are
* aborted on any navigation. * aborted on any navigation.
* Set to true to keep the dialog open for same origin navigation. * Set to true to keep the dialog open for same origin navigation.
* @param {Number} [aOptions.modalType] - The modal type to create the dialog for.
* By default, we show the dialog for tab prompts.
* @returns {Promise} - Resolves once the dialog has been closed. * @returns {Promise} - Resolves once the dialog has been closed.
*/ */
open( open(
@ -8955,32 +8949,22 @@ class TabDialogBox {
allowDuplicateDialogs = true, allowDuplicateDialogs = true,
sizeTo, sizeTo,
keepOpenSameOriginNav, keepOpenSameOriginNav,
modalType = null,
} = {}, } = {},
...aParams ...aParams
) { ) {
return new Promise(resolve => { return new Promise(resolve => {
// Get the dialog manager to open the prompt with. if (!this._dialogManager.hasDialogs) {
let dialogManager =
modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT
? this.getContentDialogManager()
: this._tabDialogManager;
let hasDialogs =
this._tabDialogManager.hasDialogs ||
this._contentDialogManager?.hasDialogs;
if (!hasDialogs) {
this._onFirstDialogOpen(); this._onFirstDialogOpen();
} }
let closingCallback = () => { let closingCallback = () => {
if (!hasDialogs) { if (!this._dialogManager.hasDialogs) {
this._onLastDialogClose(); this._onLastDialogClose();
} }
}; };
// Open dialog and resolve once it has been closed // Open dialog and resolve once it has been closed
let dialog = dialogManager.open( let dialog = this._dialogManager.open(
aURL, aURL,
{ {
features, features,
@ -9025,29 +9009,6 @@ class TabDialogBox {
this.tab?.removeEventListener("TabClose", this); this.tab?.removeEventListener("TabClose", this);
} }
_buildContentPromptDialog() {
let template = document.getElementById("dialogStackTemplate");
let contentDialogStack = template.content.cloneNode(true).firstElementChild;
contentDialogStack.classList.add("content-prompt-dialog");
// Create a dialog manager for content prompts.
let tabPromptDialog = this.browser.parentNode.querySelector(
".tab-prompt-dialog"
);
this.browser.parentNode.insertBefore(contentDialogStack, tabPromptDialog);
let contentDialogTemplate = contentDialogStack.firstElementChild;
this._contentDialogManager = new SubDialogManager({
dialogStack: contentDialogStack,
dialogTemplate: contentDialogTemplate,
orderType: SubDialogManager.ORDER_QUEUE,
allowDuplicateDialogs: true,
dialogOptions: {
consumeOutsideClicks: false,
},
});
}
handleEvent(event) { handleEvent(event) {
if (event.type !== "TabClose") { if (event.type !== "TabClose") {
return; return;
@ -9056,17 +9017,11 @@ class TabDialogBox {
} }
abortAllDialogs() { abortAllDialogs() {
this._tabDialogManager.abortDialogs(); this._dialogManager.abortDialogs();
this._contentDialogManager?.abortDialogs();
} }
focus() { focus() {
// Prioritize focusing the dialog manager for tab prompts this._dialogManager.focusTopDialog();
if (this._tabDialogManager._dialogs.length) {
this._tabDialogManager.focusTopDialog();
return;
}
this._contentDialogManager?.focusTopDialog();
} }
/** /**
@ -9096,8 +9051,7 @@ class TabDialogBox {
this._lastPrincipal = this.browser.contentPrincipal; this._lastPrincipal = this.browser.contentPrincipal;
this._tabDialogManager.abortDialogs(filterFn); this._dialogManager.abortDialogs(filterFn);
this._contentDialogManager?.abortDialogs(filterFn);
} }
get tab() { get tab() {
@ -9112,15 +9066,8 @@ class TabDialogBox {
return browser; return browser;
} }
getTabDialogManager() { getManager() {
return this._tabDialogManager; return this._dialogManager;
}
getContentDialogManager() {
if (!this._contentDialogManager) {
this._buildContentPromptDialog();
}
return this._contentDialogManager;
} }
} }

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

@ -2,9 +2,8 @@
support-files = support-files =
subdialog.xhtml subdialog.xhtml
[browser_tabdialogbox_content_prompts.js]
[browser_tabdialogbox_navigation.js] [browser_tabdialogbox_navigation.js]
[browser_tabdialogbox_tab_switch_focus.js] [browser_tabdialogbox_tab_switch_focus.js]
[browser_subdialog_esc.js] [browser_subdialog_esc.js]
support-files = support-files =
loadDelayedReply.sjs loadDelayedReply.sjs

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

@ -30,7 +30,7 @@ add_task(async function test_subdialog_esc_does_not_cancel_load() {
keepOpenSameOriginNav: true, keepOpenSameOriginNav: true,
}); });
let dialogs = dialogBox.getTabDialogManager()._dialogs; let dialogs = dialogBox._dialogManager._dialogs;
is(dialogs.length, 1, "Dialog manager has a dialog."); is(dialogs.length, 1, "Dialog manager has a dialog.");
@ -68,7 +68,7 @@ add_task(async function test_subdialog_esc_on_dropdown_does_not_close_dialog() {
keepOpenSameOriginNav: true, keepOpenSameOriginNav: true,
}); });
let dialogs = dialogBox.getTabDialogManager()._dialogs; let dialogs = dialogBox._dialogManager._dialogs;
is(dialogs.length, 1, "Dialog manager has a dialog."); is(dialogs.length, 1, "Dialog manager has a dialog.");

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

@ -1,44 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const PROTON_PREF = "browser.proton.enabled";
const TEST_ROOT_CHROME = getRootDirectory(gTestPath);
const TEST_DIALOG_PATH = TEST_ROOT_CHROME + "subdialog.xhtml";
/**
* Test that a manager for content prompts is added to tab dialog box.
*/
add_task(async function test_tabdialog_content_prompts() {
await BrowserTestUtils.withNewTab("http://example.com", async function(
browser
) {
await SpecialPowers.pushPrefEnv({
set: [[PROTON_PREF, true]],
});
info("Open a tab prompt.");
let dialogBox = gBrowser.getTabDialogBox(browser);
dialogBox.open(TEST_DIALOG_PATH);
info("Check the content prompt dialog is only created when needed.");
let contentPromptDialog = document.querySelector(".content-prompt-dialog");
ok(!contentPromptDialog, "Content prompt dialog should not be created.");
info("Open a content prompt");
dialogBox.open(TEST_DIALOG_PATH, {
modalType: Ci.nsIPrompt.MODAL_TYPE_CONTENT,
});
contentPromptDialog = document.querySelector(".content-prompt-dialog");
ok(contentPromptDialog, "Content prompt dialog should be created.");
let contentPromptManager = dialogBox.getContentDialogManager();
is(
contentPromptManager._dialogs.length,
1,
"Content prompt manager should have 1 dialog box."
);
});
});

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

@ -20,7 +20,7 @@ add_task(async function test_tabdialogbox_multiple_close_on_nav() {
dialogBox.open(TEST_DIALOG_PATH), dialogBox.open(TEST_DIALOG_PATH),
]; ];
let dialogs = dialogBox.getTabDialogManager()._dialogs; let dialogs = dialogBox._dialogManager._dialogs;
is(dialogs.length, 2, "Dialog manager has two dialogs."); is(dialogs.length, 2, "Dialog manager has two dialogs.");
@ -48,10 +48,10 @@ add_task(async function test_tabdialogbox_close_on_content_nav() {
let dialogBox = gBrowser.getTabDialogBox(browser); let dialogBox = gBrowser.getTabDialogBox(browser);
let closedPromise = dialogBox.open(TEST_DIALOG_PATH); let closedPromise = dialogBox.open(TEST_DIALOG_PATH);
let dialog = dialogBox.getTabDialogManager()._topDialog; let dialog = dialogBox._dialogManager._topDialog;
is( is(
dialogBox.getTabDialogManager()._dialogs.length, dialogBox._dialogManager._dialogs.length,
1, 1,
"Dialog manager has one dialog." "Dialog manager has one dialog."
); );
@ -116,16 +116,16 @@ add_task(async function test_tabdialogbox_hide() {
) { ) {
// Open a dialog and wait for it to be ready // Open a dialog and wait for it to be ready
let dialogBox = gBrowser.getTabDialogBox(browser); let dialogBox = gBrowser.getTabDialogBox(browser);
let dialogBoxManager = dialogBox.getTabDialogManager(); let dialogBoxManager = dialogBox.getManager();
let closedPromises = [ let closedPromises = [
dialogBox.open(TEST_DIALOG_PATH), dialogBox.open(TEST_DIALOG_PATH),
dialogBox.open(TEST_DIALOG_PATH), dialogBox.open(TEST_DIALOG_PATH),
]; ];
let dialogs = dialogBox.getTabDialogManager()._dialogs; let dialogs = dialogBox._dialogManager._dialogs;
is( is(
dialogBox.getTabDialogManager()._dialogs.length, dialogBox._dialogManager._dialogs.length,
2, 2,
"Dialog manager has two dialogs." "Dialog manager has two dialogs."
); );

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

@ -30,7 +30,7 @@ add_task(async function test_tabdialogbox_tab_switch_focus() {
for (let i = 0; i < 2; i += 1) { for (let i = 0; i < 2; i += 1) {
let dialogBox = gBrowser.getTabDialogBox(tabs[i].linkedBrowser); let dialogBox = gBrowser.getTabDialogBox(tabs[i].linkedBrowser);
dialogBox.open(TEST_DIALOG_PATH); dialogBox.open(TEST_DIALOG_PATH);
dialogs.push(dialogBox.getTabDialogManager()._topDialog); dialogs.push(dialogBox._dialogManager._topDialog);
} }
// Wait for dialogs to be ready // Wait for dialogs to be ready
@ -100,7 +100,7 @@ add_task(async function test_tabdialogbox_tab_switch_hidden() {
dialogBox = gBrowser.getTabDialogBox(tabs[i].linkedBrowser); dialogBox = gBrowser.getTabDialogBox(tabs[i].linkedBrowser);
browser = tabs[i].linkedBrowser; browser = tabs[i].linkedBrowser;
dialogBox.open(TEST_DIALOG_PATH); dialogBox.open(TEST_DIALOG_PATH);
dialogBoxManager = dialogBox.getTabDialogManager(); dialogBoxManager = dialogBox.getManager();
dialogs.push(dialogBoxManager._topDialog); dialogs.push(dialogBoxManager._topDialog);
} }
@ -121,7 +121,7 @@ add_task(async function test_tabdialogbox_tab_switch_hidden() {
// Check the dialog stack is showing in first tab // Check the dialog stack is showing in first tab
dialogBoxManager = gBrowser dialogBoxManager = gBrowser
.getTabDialogBox(tabs[0].linkedBrowser) .getTabDialogBox(tabs[0].linkedBrowser)
.getTabDialogManager(); .getManager();
is(dialogBoxManager._dialogStack.hidden, false, "Dialog stack is showing"); is(dialogBoxManager._dialogStack.hidden, false, "Dialog stack is showing");
// Cleanup // Cleanup

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

@ -70,9 +70,8 @@ modal.findModalDialogs = function(context) {
// This is for prompts that are shown in SubDialogs in the browser chrome. // This is for prompts that are shown in SubDialogs in the browser chrome.
if (context.tab && context.tabBrowser.getTabDialogBox) { if (context.tab && context.tabBrowser.getTabDialogBox) {
let contentBrowser = context.contentBrowser; let contentBrowser = context.contentBrowser;
let dialogManager = context.tabBrowser let dialogManager = context.tabBrowser.getTabDialogBox(contentBrowser)
.getTabDialogBox(contentBrowser) ._dialogManager;
.getTabDialogManager();
let dialogs = dialogManager._dialogs.filter( let dialogs = dialogManager._dialogs.filter(
dialog => dialog._openedURL === COMMON_DIALOG dialog => dialog._openedURL === COMMON_DIALOG
); );

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

@ -150,7 +150,7 @@ add_task(async function test_protocolHandler() {
let window = await windowOpen; let window = await windowOpen;
let gBrowser = window.gBrowser let gBrowser = window.gBrowser
let tabDialogBox = gBrowser.getTabDialogBox(gBrowser.selectedBrowser); let tabDialogBox = gBrowser.getTabDialogBox(gBrowser.selectedBrowser);
let dialogStack = tabDialogBox.getTabDialogManager()._dialogStack; let dialogStack = tabDialogBox._dialogManager._dialogStack;
let checkFn = dialogEvent => let checkFn = dialogEvent =>
dialogEvent.detail.dialog?._openedURL == CONTENT_HANDLING_URL; dialogEvent.detail.dialog?._openedURL == CONTENT_HANDLING_URL;

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

@ -278,7 +278,7 @@ var PrintEventHandler = {
let sourceBrowser = this.getSourceBrowsingContext().top.embedderElement; let sourceBrowser = this.getSourceBrowsingContext().top.embedderElement;
let dialogBoxManager = gBrowser let dialogBoxManager = gBrowser
.getTabDialogBox(sourceBrowser) .getTabDialogBox(sourceBrowser)
.getTabDialogManager(); .getManager();
dialogBoxManager.hideDialog(sourceBrowser); dialogBoxManager.hideDialog(sourceBrowser);
// Use our settings to prepopulate the system dialog. // Use our settings to prepopulate the system dialog.

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

@ -118,7 +118,7 @@ var PrintUtils = {
getPreviewBrowser(sourceBrowser) { getPreviewBrowser(sourceBrowser) {
let dialogBox = gBrowser.getTabDialogBox(sourceBrowser); let dialogBox = gBrowser.getTabDialogBox(sourceBrowser);
for (let dialog of dialogBox.getTabDialogManager()._dialogs) { for (let dialog of dialogBox._dialogManager._dialogs) {
let browser = dialog._box.querySelector(".printPreviewBrowser"); let browser = dialog._box.querySelector(".printPreviewBrowser");
if (browser) { if (browser) {
return browser; return browser;

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

@ -175,8 +175,9 @@ add_task(async function test_focused_browsing_context() {
() => () =>
gBrowser gBrowser
.getTabDialogBox(newTabBrowser) .getTabDialogBox(newTabBrowser)
.getTabDialogManager() ._dialogManager._dialogs.find(dlg =>
._dialogs.find(dlg => dlg._box.querySelector(".printSettingsBrowser")), dlg._box.querySelector(".printSettingsBrowser")
),
"Wait for dialog" "Wait for dialog"
); );
await dialog._dialogReady; await dialog._dialogReady;

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

@ -277,11 +277,11 @@ class PrintHelper {
} }
get _tabDialogBoxManager() { get _tabDialogBoxManager() {
return this._tabDialogBox.getTabDialogManager(); return this._tabDialogBox.getManager();
} }
get _dialogs() { get _dialogs() {
return this._tabDialogBox.getTabDialogManager()._dialogs; return this._tabDialogBox._dialogManager._dialogs;
} }
get dialog() { get dialog() {

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

@ -161,9 +161,9 @@ add_task(async function test_multiple_dialogs() {
// Check we only have one dialog // Check we only have one dialog
let tabDialogBox = gBrowser.getTabDialogBox(tab.linkedBrowser); let tabDialogBox = gBrowser.getTabDialogBox(tab.linkedBrowser);
let dialogs = tabDialogBox let dialogs = tabDialogBox._dialogManager._dialogs.filter(
.getTabDialogManager() d => d._openedURL == CONTENT_HANDLING_URL
._dialogs.filter(d => d._openedURL == CONTENT_HANDLING_URL); );
is(dialogs.length, 1, "Should only have 1 dialog open"); is(dialogs.length, 1, "Should only have 1 dialog open");

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

@ -129,7 +129,7 @@ async function waitForSubDialog(browser, url, state) {
let eventStr = state ? "dialogopen" : "dialogclose"; let eventStr = state ? "dialogopen" : "dialogclose";
let tabDialogBox = gBrowser.getTabDialogBox(browser); let tabDialogBox = gBrowser.getTabDialogBox(browser);
let dialogStack = tabDialogBox.getTabDialogManager()._dialogStack; let dialogStack = tabDialogBox._dialogManager._dialogStack;
let checkFn; let checkFn;