Skip to content

Commit

Permalink
Bug 1721982 - [marionette] Use domwindowopened observer to detect new…
Browse files Browse the repository at this point in the history
…ly opened windows. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D120734
  • Loading branch information
whimboo committed Jul 26, 2021
1 parent bd33c9c commit 8fdd8d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions remote/marionette/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ modal.DialogObserver = class {

register() {
Services.obs.addObserver(this, "common-dialog-loaded");
Services.obs.addObserver(this, "domwindowopened");
Services.obs.addObserver(this, "tabmodal-dialog-loaded");
Services.obs.addObserver(this, "toplevel-window-ready");

// Register event listener for all already open windows
for (let win of Services.wm.getEnumerator(null)) {
Expand All @@ -121,8 +121,8 @@ modal.DialogObserver = class {

unregister() {
Services.obs.removeObserver(this, "common-dialog-loaded");
Services.obs.removeObserver(this, "domwindowopened");
Services.obs.removeObserver(this, "tabmodal-dialog-loaded");
Services.obs.removeObserver(this, "toplevel-window-ready");

// Unregister event listener for all open windows
for (let win of Services.wm.getEnumerator(null)) {
Expand Down Expand Up @@ -200,7 +200,7 @@ modal.DialogObserver = class {
);
break;

case "toplevel-window-ready":
case "domwindowopened":
subject.addEventListener("DOMModalDialogClosed", this);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion remote/marionette/test/xpcshell/test_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ add_test(function test_registerDialogClosedEventHandler() {
},
};

observer.observe(mockChromeWindow, "toplevel-window-ready");
observer.observe(mockChromeWindow, "domwindowopened");
});

add_test(function test_handleCallbackOpenModalDialog() {
Expand Down

0 comments on commit 8fdd8d1

Please sign in to comment.