зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1849308 - [remote] Clean up tabmodal-dialog-loaded observer listener. r=webdriver-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D186234
This commit is contained in:
Родитель
acc51e7036
Коммит
1f250a7b7a
|
@ -719,7 +719,7 @@ export class Page extends Domain {
|
|||
*/
|
||||
_onDialogLoaded(e, data) {
|
||||
const { message, type } = data;
|
||||
// XXX: We rely on the tabmodal-dialog-loaded event (see DialogHandler.jsm)
|
||||
// XXX: We rely on the common-dialog-loaded event (see DialogHandler.jsm)
|
||||
// which is inconsistent with the name "javascriptDialogOpening".
|
||||
// For correctness we should rely on an event fired _before_ the prompt is
|
||||
// visible, such as DOMWillOpenModalDialog. However the payload of this
|
||||
|
|
|
@ -32,13 +32,11 @@ export class DialogHandler {
|
|||
this._browser = browser;
|
||||
|
||||
this._onCommonDialogLoaded = this._onCommonDialogLoaded.bind(this);
|
||||
this._onTabDialogLoaded = this._onTabDialogLoaded.bind(this);
|
||||
|
||||
Services.obs.addObserver(
|
||||
this._onCommonDialogLoaded,
|
||||
"common-dialog-loaded"
|
||||
);
|
||||
Services.obs.addObserver(this._onTabDialogLoaded, "tabmodal-dialog-loaded");
|
||||
}
|
||||
|
||||
destructor() {
|
||||
|
@ -49,10 +47,6 @@ export class DialogHandler {
|
|||
this._onCommonDialogLoaded,
|
||||
"common-dialog-loaded"
|
||||
);
|
||||
Services.obs.removeObserver(
|
||||
this._onTabDialogLoaded,
|
||||
"tabmodal-dialog-loaded"
|
||||
);
|
||||
}
|
||||
|
||||
async handleJavaScriptDialog({ accept, promptText }) {
|
||||
|
@ -121,20 +115,4 @@ export class DialogHandler {
|
|||
|
||||
this.emit("dialog-loaded", { message, type });
|
||||
}
|
||||
|
||||
_onTabDialogLoaded(promptContainer) {
|
||||
const prompts = this._browser.tabModalPromptBox.listPrompts();
|
||||
const prompt = prompts.find(p => p.ui.promptContainer === promptContainer);
|
||||
|
||||
if (!prompt) {
|
||||
// The dialog is not for the current tab.
|
||||
return;
|
||||
}
|
||||
|
||||
this._dialog = prompt;
|
||||
const message = this._dialog.args.text;
|
||||
const type = this._getDialogType();
|
||||
|
||||
this.emit("dialog-loaded", { message, type });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,6 @@ modal.DialogObserver = class {
|
|||
Services.obs.addObserver(this, "common-dialog-loaded");
|
||||
Services.obs.addObserver(this, "domwindowopened");
|
||||
Services.obs.addObserver(this, "geckoview-prompt-show");
|
||||
Services.obs.addObserver(this, "tabmodal-dialog-loaded");
|
||||
|
||||
// Register event listener for all already open windows
|
||||
for (let win of Services.wm.getEnumerator(null)) {
|
||||
|
@ -127,7 +126,6 @@ modal.DialogObserver = class {
|
|||
Services.obs.removeObserver(this, "common-dialog-loaded");
|
||||
Services.obs.removeObserver(this, "domwindowopened");
|
||||
Services.obs.removeObserver(this, "geckoview-prompt-show");
|
||||
Services.obs.removeObserver(this, "tabmodal-dialog-loaded");
|
||||
|
||||
// Unregister event listener for all open windows
|
||||
for (let win of Services.wm.getEnumerator(null)) {
|
||||
|
@ -161,22 +159,6 @@ modal.DialogObserver = class {
|
|||
|
||||
let curBrowser = this._curBrowserFn();
|
||||
switch (topic) {
|
||||
// This topic is only used by the old-style content modal dialogs like
|
||||
// alert, confirm, and prompt. It can be removed when only the new
|
||||
// subdialog based content modals remain. Those will be made default in
|
||||
// Firefox 89, and this case is deprecated.
|
||||
case "tabmodal-dialog-loaded":
|
||||
const container = curBrowser.contentBrowser.closest(
|
||||
".browserSidebarContainer"
|
||||
);
|
||||
if (!container.contains(subject)) {
|
||||
return;
|
||||
}
|
||||
this.callbacks.forEach(callback =>
|
||||
callback(modal.ACTION_OPENED, subject)
|
||||
);
|
||||
break;
|
||||
|
||||
case "common-dialog-loaded":
|
||||
if (curBrowser) {
|
||||
if (
|
||||
|
|
Загрузка…
Ссылка в новой задаче