Bug 1553356 - Fix browser_webconsole_warning_groups_filtering.js intermittent. r=Ola.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 19 Jun 2019 12:07:37 +0000
changeset 479221 ddbad8f00d6121a64802e7890b5f81986899320f
parent 479220 289805d6054ddc04c5d687353a9237f2874db550
child 479222 f79736d79ee10a1d26cbf42ec9fe02a303b74e22
push id36174
push useropoprus@mozilla.com
push dateWed, 19 Jun 2019 21:38:13 +0000
treeherdermozilla-central@5b9a3de04646 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersOla
bugs1553356
milestone69.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 1553356 - Fix browser_webconsole_warning_groups_filtering.js intermittent. r=Ola. The failures indicated that some warning messages were placed before the navigation marker, when they should be placed after. We now listen to the `load` event instead of `DOMContentLoaded` to ensure the page is fully loaded and the warning gets reported into the right page session. Differential Revision: https://phabricator.services.mozilla.com/D35014
devtools/client/webconsole/test/mochitest/browser_webconsole_warning_group_multiples.js
devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups.js
devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_filtering.js
devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_toggle.js
devtools/client/webconsole/test/mochitest/head.js
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_group_multiples.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_group_multiples.js
@@ -138,22 +138,17 @@ add_task(async function testContentBlock
     `▼︎⚠ ${STORAGE_BLOCKED_GROUP_LABEL}`,
     `| ${STORAGE_BLOCKED_URL}?3`,
     `| ${STORAGE_BLOCKED_URL}?4`,
     `| ${STORAGE_BLOCKED_URL}?5`,
     `simple message 2`,
   ]);
 
   info("Reload the page and wait for it to be ready");
-  const onDomContentLoaded = BrowserTestUtils.waitForContentEvent(
-    hud.target.tab.linkedBrowser, "DOMContentLoaded", true);
-  ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
-    content.location.reload();
-  });
-  await onDomContentLoaded;
+  await reloadPage();
 
   // Also wait for the navigation message to be displayed.
   await waitFor(() => findMessage(hud, "Navigated to"));
 
   info("Add a storage blocked message and a content blocked one");
   onStorageBlockedMessage = waitForMessage(hud, STORAGE_BLOCKED_URL, ".warn");
   emitStorageAccessBlockedMessage(hud);
   await onStorageBlockedMessage;
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups.js
@@ -102,22 +102,17 @@ add_task(async function testContentBlock
     `| ${BLOCKED_URL}?2`,
     `| ${BLOCKED_URL}?3`,
     `| ${BLOCKED_URL}?4`,
     `simple message 1`,
     `simple message 2`,
   ]);
 
   info("Reload the page and wait for it to be ready");
-  const onDomContentLoaded = BrowserTestUtils.waitForContentEvent(
-    hud.target.tab.linkedBrowser, "DOMContentLoaded", true);
-  ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
-    content.location.reload();
-  });
-  await onDomContentLoaded;
+  await reloadPage();
 
   // Also wait for the navigation message to be displayed.
   await waitFor(() => findMessage(hud, "Navigated to"));
 
   info("Log a tracking protection message to check it is not grouped");
   onContentBlockingWarningMessage =
     waitForMessage(hud, BLOCKED_URL, ".warn");
   emitContentBlockedMessage(hud);
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_filtering.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_filtering.js
@@ -43,22 +43,17 @@ add_task(async function testContentBlock
   const warningGroupMessage1 = (await onContentBlockingWarningGroupMessage).node;
   await logString(hud, "simple message 2");
   emitContentBlockedMessage(hud);
   await waitForBadgeNumber(warningGroupMessage1, "3");
   emitContentBlockedMessage(hud);
   await waitForBadgeNumber(warningGroupMessage1, "4");
 
   info("Reload the page and wait for it to be ready");
-  const onDomContentLoaded = BrowserTestUtils.waitForContentEvent(
-    hud.target.tab.linkedBrowser, "DOMContentLoaded", true);
-  ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
-    content.location.reload();
-  });
-  await onDomContentLoaded;
+  await reloadPage();
 
   // Wait for the navigation message to be displayed.
   await waitFor(() => findMessage(hud, "Navigated to"));
   onContentBlockingWarningMessage = waitForMessage(hud, BLOCKED_URL, ".warn");
   emitContentBlockedMessage(hud);
   await onContentBlockingWarningMessage;
   await logString(hud, "simple message 3");
   onContentBlockingWarningGroupMessage =
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_toggle.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_warning_groups_toggle.js
@@ -106,22 +106,17 @@ add_task(async function testContentBlock
     `| ${BLOCKED_URL}?1`,
     `| ${BLOCKED_URL}?2`,
     `| ${BLOCKED_URL}?3`,
     `| ${BLOCKED_URL}?4`,
     `simple message 1`,
   ]);
 
   info("Reload the page and wait for it to be ready");
-  const onDomContentLoaded = BrowserTestUtils.waitForContentEvent(
-    hud.target.tab.linkedBrowser, "DOMContentLoaded", true);
-  ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
-    content.location.reload();
-  });
-  await onDomContentLoaded;
+  await reloadPage();
 
   // Wait for the navigation message to be displayed.
   await waitFor(() => findMessage(hud, "Navigated to"));
 
   info("Disable the warningGroup feature pref again");
   await toggleWarningGroupPreference(hud, false);
 
   info("Add one warning message and one simple message");
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -1371,8 +1371,22 @@ async function checkMessageStack(hud, te
   const framesNode = await waitFor(() => msgNode.querySelector(".frames"));
   const frameNodes = framesNode.querySelectorAll(".frame");
   ok(frameNodes.length == frameLines.length, `Found ${frameLines.length} frames`);
   for (let i = 0; i < frameLines.length; i++) {
     ok(frameNodes[i].querySelector(".line").textContent == "" + frameLines[i],
        `Found line ${frameLines[i]} for frame #${i}`);
   }
 }
+
+/**
+ * Reload the content page.
+ * @returns {Promise} A promise that will return when the page is fully loaded (i.e., the
+ *                    `load` event was fired).
+ */
+function reloadPage() {
+  const onLoad = BrowserTestUtils.waitForContentEvent(
+    gBrowser.selectedBrowser, "load", true);
+  ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
+    content.location.reload();
+  });
+  return onLoad;
+}