Bug 1637562: Add test for ignoreExistingResources flag for platform messages. r=ochameau,nchevobbe
authorDaisuke Akatsuka <daisuke@birchill.co.jp>
Wed, 20 May 2020 08:16:32 +0000
changeset 530972 366f83055635d1a6f00527f475d59eebccef2069
parent 530971 44167342f7f064dfb2966c259401775221df3086
child 530973 bf1aa383a8fe2f5681bcfe0c05eb027ebc6d248a
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 platform messages. r=ochameau,nchevobbe Depends on D75750 Differential Revision: https://phabricator.services.mozilla.com/D75751
devtools/shared/resources/tests/browser_resources_platform_messages.js
--- a/devtools/shared/resources/tests/browser_resources_platform_messages.js
+++ b/devtools/shared/resources/tests/browser_resources_platform_messages.js
@@ -72,8 +72,63 @@ add_task(async function() {
   info("Waiting for all expected messages to be received");
   await onAllMessagesReceived;
   ok(true, "All the expected messages were received");
 
   Services.console.reset();
   targetList.stopListening();
   await client.close();
 });
+
+add_task(async function() {
+  info("Test ignoreExistingResources option for PLATFORM_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 {
+    client,
+    resourceWatcher,
+    targetList,
+  } = await initResourceWatcherAndTarget();
+
+  info(
+    "Check whether onAvailable will not be called with existing platform messages"
+  );
+  const expectedMessages = ["This is 1st message", "This is 2nd message"];
+  Services.console.logStringMessage(expectedMessages[0]);
+  Services.console.logStringMessage(expectedMessages[1]);
+
+  const availableResources = [];
+  await resourceWatcher.watch([ResourceWatcher.TYPES.PLATFORM_MESSAGES], {
+    onAvailable: ({ resource }) => {
+      if (!expectedMessages.includes(resource.message)) {
+        return;
+      }
+
+      availableResources.push(resource);
+    },
+    ignoreExistingResources: true,
+  });
+  is(
+    availableResources.length,
+    0,
+    "onAvailable wasn't called for existing platform messages"
+  );
+
+  info(
+    "Check whether onAvailable will be called with the future platform messages"
+  );
+  Services.console.logStringMessage(expectedMessages[0]);
+  Services.console.logStringMessage(expectedMessages[1]);
+
+  await waitUntil(() => availableResources.length === expectedMessages.length);
+  for (let i = 0; i < expectedMessages.length; i++) {
+    const { message } = availableResources[i];
+    const expected = expectedMessages[i];
+    is(message, expected, `Message[${i}] is correct`);
+  }
+
+  Services.console.reset();
+  await targetList.stopListening();
+  await client.close();
+});