diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/base/test/browser_chromeutils_getalldomprocesses.js | |
parent | Initial commit. (diff) | |
download | firefox-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 'dom/base/test/browser_chromeutils_getalldomprocesses.js')
-rw-r--r-- | dom/base/test/browser_chromeutils_getalldomprocesses.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/base/test/browser_chromeutils_getalldomprocesses.js b/dom/base/test/browser_chromeutils_getalldomprocesses.js new file mode 100644 index 0000000000..0e94d5566d --- /dev/null +++ b/dom/base/test/browser_chromeutils_getalldomprocesses.js @@ -0,0 +1,69 @@ +add_task(async function testParentProcess() { + const [parentProcess] = ChromeUtils.getAllDOMProcesses(); + // browser.xhtml is in the parent process, so its domProcess is the parent process one + is( + parentProcess, + window.browsingContext.currentWindowGlobal.domProcess, + "The first element is the parent process" + ); + is( + parentProcess.osPid, + Services.appinfo.processID, + "We got the right OS Pid" + ); + is(parentProcess.childID, 0, "Parent process has childID set to 0"); +}); + +add_task(async function testContentProcesses() { + info("Open a tab in a content process"); + BrowserTestUtils.startLoadingURIString( + gBrowser.selectedBrowser, + "about:blank" + ); + await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + + info("Sanity checks against all returned elements of getAllDOMProcesses"); + const processes = ChromeUtils.getAllDOMProcesses(); + const allPids = [], + allChildIDs = []; + for (const process of processes) { + ok( + process instanceof Ci.nsIDOMProcessParent, + `Each element of the array is a nsIDOMProcessParent (${process})` + ); + Assert.greater(process.osPid, 0, `OS Pid looks correct ${process.osPid}`); + if (process == processes[0]) { + is( + process.childID, + 0, + `Child ID is 0 for the parent process, which is the first element of the returned array` + ); + is( + process.remoteType, + null, + "The main process's remote type should be NOT_REMOTE" + ); + } else { + Assert.greater( + process.childID, + 0, + `Child ID looks also correct ${process.childID}` + ); + ok(process.remoteType, "Should have a remote type"); + } + + ok( + !allPids.includes(process.osPid), + "We only get one nsIDOMProcessParent per OS process == each osPid is different" + ); + allPids.push(process.osPid); + ok(!allChildIDs.includes(process.childID), "Each childID is different"); + allChildIDs.push(process.childID); + } + + info("Search for the nsIDOMProcessParent for the opened tab"); + const { currentWindowGlobal } = gBrowser.selectedBrowser.browsingContext; + const tabProcess = currentWindowGlobal.domProcess; + ok(processes.includes(tabProcess), "Found the tab process in the list"); + is(tabProcess.osPid, currentWindowGlobal.osPid, "We got the right OS Pid"); +}); |