Bug 1680637 - Rename TabDialogBox's manager to tabDialogManager r=marionette-reviewers,Gijs

To clarify the two separate SubDialog managers managed by TabDialogManager, this patch renames `_.dialogManager` to `._tabDialogManager`.

Depends on D100066

Differential Revision: https://phabricator.services.mozilla.com/D100955
This commit is contained in:
Micah Tigley 2021-01-11 20:55:19 +00:00
Родитель ebb0c0923f
Коммит c0ec6961ed
12 изменённых файлов: 39 добавлений и 37 удалений

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

@ -8894,9 +8894,10 @@ const SafeBrowsingNotificationBox = {
};
/**
* The TabDialogBox supports opening window dialogs as SubDialogs on tab level.
* The TabDialogBox supports opening window dialogs as SubDialogs on the tab and content
* level. Both tab and content dialogs have their own separate managers.
* Dialogs will be queued FIFO and cover the web content.
* Tab dialogs are closed when the user reloads or leaves the page.
* Dialogs are closed when the user reloads or leaves the page.
* While a dialog is open PopupNotifications, such as permission prompts, are
* suppressed.
*/
@ -8904,7 +8905,7 @@ class TabDialogBox {
constructor(browser) {
this._weakBrowserRef = Cu.getWeakReference(browser);
// Create parent element for dialogs
// Create parent element for tab dialogs
let template = document.getElementById("dialogStackTemplate");
let dialogStack = template.content.cloneNode(true).firstElementChild;
dialogStack.classList.add("tab-prompt-dialog");
@ -8917,7 +8918,8 @@ class TabDialogBox {
// Initially the stack only contains the template
let dialogTemplate = dialogStack.firstElementChild;
this._dialogManager = new SubDialogManager({
// Create dialog manager for prompts at the tab level.
this._tabDialogManager = new SubDialogManager({
dialogStack,
dialogTemplate,
orderType: SubDialogManager.ORDER_QUEUE,
@ -8962,9 +8964,9 @@ class TabDialogBox {
let dialogManager =
modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT
? this.getContentDialogManager()
: this._dialogManager;
: this._tabDialogManager;
let hasDialogs =
this._dialogManager.hasDialogs ||
this._tabDialogManager.hasDialogs ||
this._contentDialogManager?.hasDialogs;
if (!hasDialogs) {
@ -9054,14 +9056,14 @@ class TabDialogBox {
}
abortAllDialogs() {
this._dialogManager.abortDialogs();
this._tabDialogManager.abortDialogs();
this._contentDialogManager?.abortDialogs();
}
focus() {
// Prioritize focusing the dialog manager for tab prompts
if (this._dialogManager._dialogs.length) {
this._dialogManager.focusTopDialog();
if (this._tabDialogManager._dialogs.length) {
this._tabDialogManager.focusTopDialog();
return;
}
this._contentDialogManager?.focusTopDialog();
@ -9094,7 +9096,7 @@ class TabDialogBox {
this._lastPrincipal = this.browser.contentPrincipal;
this._dialogManager.abortDialogs(filterFn);
this._tabDialogManager.abortDialogs(filterFn);
this._contentDialogManager?.abortDialogs(filterFn);
}
@ -9110,8 +9112,8 @@ class TabDialogBox {
return browser;
}
getManager() {
return this._dialogManager;
getTabDialogManager() {
return this._tabDialogManager;
}
getContentDialogManager() {

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

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

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

@ -20,7 +20,7 @@ add_task(async function test_tabdialogbox_multiple_close_on_nav() {
dialogBox.open(TEST_DIALOG_PATH),
];
let dialogs = dialogBox._dialogManager._dialogs;
let dialogs = dialogBox.getTabDialogManager()._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 closedPromise = dialogBox.open(TEST_DIALOG_PATH);
let dialog = dialogBox._dialogManager._topDialog;
let dialog = dialogBox.getTabDialogManager()._topDialog;
is(
dialogBox._dialogManager._dialogs.length,
dialogBox.getTabDialogManager()._dialogs.length,
1,
"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
let dialogBox = gBrowser.getTabDialogBox(browser);
let dialogBoxManager = dialogBox.getManager();
let dialogBoxManager = dialogBox.getTabDialogManager();
let closedPromises = [
dialogBox.open(TEST_DIALOG_PATH),
dialogBox.open(TEST_DIALOG_PATH),
];
let dialogs = dialogBox._dialogManager._dialogs;
let dialogs = dialogBox.getTabDialogManager()._dialogs;
is(
dialogBox._dialogManager._dialogs.length,
dialogBox.getTabDialogManager()._dialogs.length,
2,
"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) {
let dialogBox = gBrowser.getTabDialogBox(tabs[i].linkedBrowser);
dialogBox.open(TEST_DIALOG_PATH);
dialogs.push(dialogBox._dialogManager._topDialog);
dialogs.push(dialogBox.getTabDialogManager()._topDialog);
}
// 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);
browser = tabs[i].linkedBrowser;
dialogBox.open(TEST_DIALOG_PATH);
dialogBoxManager = dialogBox.getManager();
dialogBoxManager = dialogBox.getTabDialogManager();
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
dialogBoxManager = gBrowser
.getTabDialogBox(tabs[0].linkedBrowser)
.getManager();
.getTabDialogManager();
is(dialogBoxManager._dialogStack.hidden, false, "Dialog stack is showing");
// Cleanup

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -161,9 +161,9 @@ add_task(async function test_multiple_dialogs() {
// Check we only have one dialog
let tabDialogBox = gBrowser.getTabDialogBox(tab.linkedBrowser);
let dialogs = tabDialogBox._dialogManager._dialogs.filter(
d => d._openedURL == CONTENT_HANDLING_URL
);
let dialogs = tabDialogBox
.getTabDialogManager()
._dialogs.filter(d => d._openedURL == CONTENT_HANDLING_URL);
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 tabDialogBox = gBrowser.getTabDialogBox(browser);
let dialogStack = tabDialogBox._dialogManager._dialogStack;
let dialogStack = tabDialogBox.getTabDialogManager()._dialogStack;
let checkFn;