Bug 1455796 - Make browser_messagemanager_loadprocessscript.js aware of OOP WebExtensions
MozReview-Commit-ID: KENm9TmElUU
--- 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;
}