Bug 1372664 - browser_messagemanager_loadprocessscript.js fails when Activity Stream is enabled. r?krizsa
Allow for either the usual 3 base process count or with activity-stream both 3 or 4 counts.
MozReview-Commit-ID: 2VQuq4KpBPK
--- a/dom/base/test/browser_messagemanager_loadprocessscript.js
+++ b/dom/base/test/browser_messagemanager_loadprocessscript.js
@@ -1,12 +1,26 @@
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
+const BASE_NUMBER_OF_PROCESSES = 3;
+function checkBaseProcessCount(description) {
+ const {childCount} = ppmm;
+ // With preloaded activity-stream, process count is a bit undeterministic, so
+ // allow for some variation
+ if (Services.prefs.getBoolPref("browser.newtabpage.activity-stream.enabled")) {
+ const extraCount = BASE_NUMBER_OF_PROCESSES + 1;
+ ok(childCount === BASE_NUMBER_OF_PROCESSES || childCount === extraCount, `${description} (${BASE_NUMBER_OF_PROCESSES} or ${extraCount})`);
+ }
+ else {
+ is(childCount, BASE_NUMBER_OF_PROCESSES, `${description} (${BASE_NUMBER_OF_PROCESSES})`);
+ }
+}
+
function processScript() {
let cpmm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
.getService(Components.interfaces.nsISyncMessageSender);
if (cpmm !== this) {
dump("Test failed: wrong global object\n");
return;
}
@@ -71,17 +85,17 @@ add_task(async function(){
tabs[i] = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
}
for (let i = 0; i < 3; i++) {
await BrowserTestUtils.removeTab(tabs[i]);
}
ppmm.releaseCachedProcesses();
- is(ppmm.childCount, 3, "Should get back to 3 processes at this point.");
+ checkBaseProcessCount("Should get back to the base number of processes at this point");
})
// Test that loading a process script loads in all existing processes
add_task(async function() {
let checks = [];
for (let i = 0; i < ppmm.childCount; i++)
checks.push(checkProcess(ppmm.getChildAt(i)));
@@ -90,17 +104,17 @@ add_task(async function() {
});
// Test that loading a process script loads in new processes
add_task(async function() {
// This test is only relevant in e10s
if (!gMultiProcessBrowser)
return;
- is(ppmm.childCount, 3, "Should be three processes at this point");
+ checkBaseProcessCount("Should still be at the base number of processes at this point");
// Load something in the main process
gBrowser.selectedBrowser.loadURI("about:robots");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let init = ppmm.initialProcessData;
init.test123 = "hello";
init.test456 = new Map();
@@ -120,17 +134,17 @@ add_task(async function() {
await check;
check = checkProcess(ppmm);
// Reset the default browser to start a new child process
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
gBrowser.selectedBrowser.loadURI("about:blank");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
- is(ppmm.childCount, 3, "Should be back to three processes at this point");
+ checkBaseProcessCount("Should be back to the base number of processes at this point");
// The new process should have responded
await check;
ppmm.removeDelayedProcessScript(processScriptURL);
let childMM;
childMM = ppmm.getChildAt(2);