Bug 1471737 - ensure DOMFrameContentLoaded events in browser_subdialogs.js are actually for the right frame before continuing the test, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 14 Mar 2019 17:49:58 +0000
changeset 521922 495029aae21b
parent 521921 b11e72c5c268
child 521923 32112b7c202e
child 521970 49d94c83bb22
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1471737
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1471737 - ensure DOMFrameContentLoaded events in browser_subdialogs.js are actually for the right frame before continuing the test, r=jaws Differential Revision: https://phabricator.services.mozilla.com/D23548
browser/components/preferences/in-content/tests/browser_subdialogs.js
--- a/browser/components/preferences/in-content/tests/browser_subdialogs.js
+++ b/browser/components/preferences/in-content/tests/browser_subdialogs.js
@@ -18,20 +18,26 @@ function open_subdialog_and_test_generic
     let rv = { acceptCount: 0 };
     let win = content.window;
     content.gSubDialog.open(args.url, null, rv);
     let subdialog = content.gSubDialog._topDialog;
 
     info("waiting for subdialog DOMFrameContentLoaded");
     let dialogOpenPromise;
     await new Promise(resolve => {
-      win.addEventListener("DOMFrameContentLoaded", () => {
+      win.addEventListener("DOMFrameContentLoaded", function frameContentLoaded(ev) {
+        // We can get events for loads in other frames, so we have to filter
+        // those out.
+        if (ev.target != subdialog._frame) {
+          return;
+        }
+        win.removeEventListener("DOMFrameContentLoaded", frameContentLoaded);
         dialogOpenPromise = ContentTaskUtils.waitForEvent(subdialog._overlay, "dialogopen");
         resolve();
-      }, { once: true, capture: true });
+      }, { capture: true });
     });
     let result;
     if (args.domcontentloadedFnStr) {
       // eslint-disable-next-line no-eval
       result = eval(args.domcontentloadedFnStr);
     }
 
     info("waiting for subdialog load");