Bug 1455796 - Make browser_messagemanager_loadprocessscript.js aware of OOP WebExtensions draft
authorDennis Schubert <dschubert@mozilla.com>
Tue, 08 May 2018 15:18:08 +0200
changeset 792515 45f474f51093f45cd3195f06d91751d7f4f48361
parent 790321 258fa1eb49c9a559f0f75bd0a597d14398b01430
push id109119
push userbmo:dschubert@mozilla.com
push dateTue, 08 May 2018 13:18:48 +0000
bugs1455796
milestone61.0a1
Bug 1455796 - Make browser_messagemanager_loadprocessscript.js aware of OOP WebExtensions MozReview-Commit-ID: KENm9TmElUU
dom/base/test/browser_messagemanager_loadprocessscript.js
--- a/dom/base/test/browser_messagemanager_loadprocessscript.js
+++ b/dom/base/test/browser_messagemanager_loadprocessscript.js
@@ -1,15 +1,32 @@
-const BASE_NUMBER_OF_PROCESSES = 3;
+function getBaseNumberOfProcesses() {
+  // We should have three processes for this test, the parent process and two
+  // content processes for the tabs craeted by this test.
+  let processCount = 3;
+
+  // If we run WebExtensions out-of-process (see bug 1190679), there might be
+  // additional processes for those, so let's add these to the base count to
+  // not have system WebExtensions cause test failures.
+  for (let i = 0; i < Services.ppmm.childCount; i++) {
+    if (Services.ppmm.getChildAt(i).remoteType === E10SUtils.EXTENSION_REMOTE_TYPE) {
+      processCount += 1;
+    }
+  }
+
+  return processCount;
+}
+
 function checkBaseProcessCount(description) {
+  const baseProcessCount = getBaseNumberOfProcesses();
   const {childCount} = Services.ppmm;
   // With preloaded activity-stream, process count is a bit undeterministic, so
   // allow for some variation
-  const extraCount = BASE_NUMBER_OF_PROCESSES + 1;
-  ok(childCount === BASE_NUMBER_OF_PROCESSES || childCount === extraCount, `${description} (${BASE_NUMBER_OF_PROCESSES} or ${extraCount})`);
+  const extraCount = baseProcessCount + 1;
+  ok(childCount === baseProcessCount || childCount === extraCount, `${description} (${baseProcessCount} or ${extraCount})`);
 }
 
 function processScript() {
   if (Services.cpmm !== this) {
     dump("Test failed: wrong global object\n");
     return;
   }