Bug 1637562: Add test for ignoreExistingResources flag for error messages. r=ochameau,nchevobbe
authorDaisuke Akatsuka <daisuke@birchill.co.jp>
Wed, 20 May 2020 08:16:18 +0000
changeset 530971 44167342f7f064dfb2966c259401775221df3086
parent 530970 6761e905feaf3c47c282a7337af802d2c98879aa
child 530972 366f83055635d1a6f00527f475d59eebccef2069
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, nchevobbe
bugs1637562
milestone78.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 1637562: Add test for ignoreExistingResources flag for error messages. r=ochameau,nchevobbe Depends on D75749 Differential Revision: https://phabricator.services.mozilla.com/D75750
devtools/shared/resources/tests/browser_resources_error_messages.js
--- a/devtools/shared/resources/tests/browser_resources_error_messages.js
+++ b/devtools/shared/resources/tests/browser_resources_error_messages.js
@@ -83,16 +83,65 @@ add_task(async function() {
   await onAllErrorReceived;
   ok(true, "All the expected errors were received");
 
   Services.console.reset();
   targetList.stopListening();
   await client.close();
 });
 
+add_task(async function() {
+  info("Test ignoreExistingResources option for ERROR_MESSAGES");
+
+  // Disable the preloaded process as it creates processes intermittently
+  // which forces the emission of RDP requests we aren't correctly waiting for.
+  await pushPref("dom.ipc.processPrelaunch.enabled", false);
+
+  const tab = await addTab(TEST_URI);
+
+  const {
+    client,
+    resourceWatcher,
+    targetList,
+  } = await initResourceWatcherAndTarget(tab);
+
+  info(
+    "Check whether onAvailable will not be called with existing error messages"
+  );
+  await triggerErrors(tab);
+
+  const availableResources = [];
+  await resourceWatcher.watch([ResourceWatcher.TYPES.ERROR_MESSAGES], {
+    onAvailable: ({ resource }) => availableResources.push(resource),
+    ignoreExistingResources: true,
+  });
+  is(
+    availableResources.length,
+    0,
+    "onAvailable wasn't called for existing error messages"
+  );
+
+  info(
+    "Check whether onAvailable will be called with the future error messages"
+  );
+  await triggerErrors(tab);
+
+  const expectedMessages = Array.from(expectedPageErrors.values());
+  await waitUntil(() => availableResources.length === expectedMessages.length);
+  for (let i = 0; i < expectedMessages.length; i++) {
+    const { pageError } = availableResources[i];
+    const expected = expectedMessages[i];
+    checkObject(pageError, expected);
+  }
+
+  Services.console.reset();
+  await targetList.stopListening();
+  await client.close();
+});
+
 /**
  * Triggers all the errors in the content page.
  */
 async function triggerErrors(tab) {
   for (const [expression, expected] of expectedPageErrors.entries()) {
     if (
       !expected[noUncaughtException] &&
       !Services.appinfo.browserTabsRemoteAutostart