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 524920 495029aae21bbac7d75caafb3d67082715c6c63b
parent 524919 b11e72c5c2689969dca14572488b46854d027da5
child 524921 32112b7c202edccb5ec54ab18971e0a46af3ee58
child 524968 49d94c83bb220524a370fc7f7734de7e7307016b
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [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");