summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml')
-rw-r--r--toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml90
1 files changed, 90 insertions, 0 deletions
diff --git a/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml b/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml
new file mode 100644
index 0000000000..9f3cdfe774
--- /dev/null
+++ b/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xhtml
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="GC/CC logging with child processes"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ SimpleTest.waitForExplicitFinish();
+
+ let numRemotes = 3;
+ 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", numRemotes]]}).then(function() {
+ for (let i = 0; i < numRemotes; i++) {
+ let w = remotes[i] = window.browsingContext.topChromeWindow.open("remote.xhtml", "", "chrome");
+
+ w.addEventListener("load", function loadHandler() {
+ let remoteBrowser = w.document.getElementById("remote");
+ let mm = remoteBrowser.messageManager;
+ mm.addMessageListener("test:ready", function readyHandler() {
+ mm.removeMessageListener("test:ready", readyHandler);
+ numReady++;
+ if (numReady == numRemotes) {
+ // All the remote processes are ready. Run test.
+ runTest();
+ }
+ });
+ mm.loadFrameScript("data:," + encodeURI("sendAsyncMessage('test:ready');"), true);
+ }, {once: true});
+ }
+ });
+
+ let dumper = Cc["@mozilla.org/memory-info-dumper;1"].
+ getService(Ci.nsIMemoryInfoDumper);
+
+ function runTest() {
+ let numParents = 0;
+ let numChildren = 0;
+ dumper.dumpGCAndCCLogsToFile(
+ /* identifier: */ "test." + Date.now(),
+ /* allTraces: */ false,
+ /* childProcesses: */ true,
+ {
+ onDump(gcLog, ccLog, isParent) {
+ if (isParent) {
+ numParents++;
+ } else {
+ numChildren++;
+ }
+ checkAndRemoveLog(gcLog);
+ checkAndRemoveLog(ccLog);
+ },
+ onFinish() {
+ is(numParents, 1, "GC/CC logs for the parent process");
+ is(numChildren, numRemotes, "GC/CC logs for each child process");
+ cleanUpAndFinish();
+ },
+ }
+ );
+ }
+
+ function cleanUpAndFinish() {
+ // Close the remote processes.
+ for (let i = 0; i < numRemotes; i++) {
+ remotes[i].close();
+ }
+ SimpleTest.finish();
+ }
+
+ function checkAndRemoveLog(logFile) {
+ let name = logFile.path;
+ ok(logFile.exists(), "log file "+name+" exists");
+ ok(logFile.isFile(), "log file "+name+" is a regular file");
+ ok(logFile.fileSize > 0, "log file "+name+" is not empty");
+ logFile.remove(/* recursive: */ false);
+ }
+
+ ]]></script>
+</window>