Bug 1515390 - Make memory reporter tests work with the socket process. r=erahm

Differential Revision: https://phabricator.services.mozilla.com/D15022

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dragana Damjanovic 2019-01-16 22:24:57 +00:00
parent fc155bc720
commit 08382f397b
4 changed files with 27 additions and 10 deletions

View File

@ -24,6 +24,10 @@
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
getService(Ci.nsIMemoryReporterManager);
let socketProcessRunning = 0;
if (SpecialPowers.getBoolPref("network.process.enabled")) {
socketProcessRunning = 1;
}
let numRemotes = 3;
let numReady = 0;
@ -128,7 +132,8 @@
if (endOfBrowsers == null) {
endOfBrowsers = actual.match(/End of Web Content/g);
}
let m2 = (vsizes.length == 4 && endOfBrowsers.length == 3);
let m2 = (vsizes.length == (4 + socketProcessRunning) &&
endOfBrowsers.length == 3);
ok(m2, "three child processes present in loaded data");
good = good && !!m2;

View File

@ -140,6 +140,11 @@
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
getService(Ci.nsIMemoryReporterManager);
let socketProcessRunning = 0;
if (SpecialPowers.getBoolPref("network.process.enabled")) {
socketProcessRunning = 1;
}
let amounts = [
"vsize",
@ -227,7 +232,8 @@
function checkSpecialReport(aName, aAmounts, aCanBeUnreasonable)
{
ok(aAmounts.length == 1, aName + " has " + aAmounts.length + " report");
ok(aAmounts.length == (1 + socketProcessRunning),
aName + " has " + aAmounts.length + " report");
let n = aAmounts[0];
if (!aCanBeUnreasonable) {
checkSizeReasonable(aName, n);

View File

@ -18,15 +18,20 @@
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
let socketProcessRunning = 0;
if (SpecialPowers.getBoolPref("network.process.enabled")) {
socketProcessRunning = 1;
}
let numRemotes = 3;
let numToOpen = 3;
const expectedNumRemotes = numToOpen + socketProcessRunning;
let numReady = 0;
// Create some remote processes, and set up message-passing so that
// we know when each child is fully initialized.
let remotes = [];
SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 3]]}, function() {
for (let i = 0; i < numRemotes; i++) {
for (let i = 0; i < numToOpen; i++) {
let w = remotes[i] = window.open("remote.xul", "", "chrome");
w.addEventListener("load", function loadHandler() {
@ -36,7 +41,7 @@
mm.addMessageListener("test:ready", function readyHandler() {
mm.removeMessageListener("test:ready", readyHandler);
numReady++;
if (numReady == numRemotes) {
if (numReady == numToOpen) {
// All the remote processes are ready. Do memory reporting.
doReports();
}
@ -71,27 +76,28 @@
);
// Close the remote processes.
for (let i = 0; i < numRemotes; i++) {
for (let i = 0; i < numToOpen; i++) {
remotes[i].close();
}
// Check the results.
let processes = Object.keys(residents);
ok(processes.length == numRemotes + 1, "correct resident count");
ok(processes.length == expectedNumRemotes + 1, "correct resident count");
let numEmptyProcesses = 0, numNonEmptyProcesses = 0;
for (let i = 0; i < processes.length; i++) {
if (processes[i] == "") {
numEmptyProcesses++;
} else {
ok(processes[i].startsWith("Browser (") || processes[i].startsWith("Web Content ("),
ok(processes[i].startsWith("Browser (") || processes[i].startsWith("Web Content (") ||
(processes[i].startsWith("SocketProcess") && socketProcessRunning),
"correct non-empty process name prefix: " + processes[i]);
numNonEmptyProcesses++;
}
}
ok(numEmptyProcesses == 1, "correct empty process name count");
ok(numNonEmptyProcesses == numRemotes,
ok(numNonEmptyProcesses == expectedNumRemotes,
"correct non-empty process name count");
SimpleTest.finish();

View File

@ -1814,7 +1814,7 @@ nsresult nsMemoryReporterManager::StartGettingReports() {
}
}
if (net::gIOService) {
if (!mIsRegistrationBlocked && net::gIOService) {
if (RefPtr<MemoryReportingProcess> proc =
net::gIOService->GetSocketProcessMemoryReporter()) {
s->mChildrenPending.AppendElement(proc.forget());