diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /remote/cdp/test/browser/systemInfo | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/cdp/test/browser/systemInfo')
-rw-r--r-- | remote/cdp/test/browser/systemInfo/browser.ini | 15 | ||||
-rw-r--r-- | remote/cdp/test/browser/systemInfo/browser_getProcessInfo.js | 78 | ||||
-rw-r--r-- | remote/cdp/test/browser/systemInfo/head.js | 9 |
3 files changed, 102 insertions, 0 deletions
diff --git a/remote/cdp/test/browser/systemInfo/browser.ini b/remote/cdp/test/browser/systemInfo/browser.ini new file mode 100644 index 0000000000..39a6218d43 --- /dev/null +++ b/remote/cdp/test/browser/systemInfo/browser.ini @@ -0,0 +1,15 @@ +[DEFAULT] +tags = cdp +subsuite = remote +args = + --remote-debugging-port + --remote-allow-origins=null +prefs = # Bug 1600054: Make CDP Fission compatible + fission.bfcacheInParent=false + fission.webContentIsolationStrategy=0 +support-files = + !/remote/cdp/test/browser/chrome-remote-interface.js + !/remote/cdp/test/browser/head.js + head.js + +[browser_getProcessInfo.js] diff --git a/remote/cdp/test/browser/systemInfo/browser_getProcessInfo.js b/remote/cdp/test/browser/systemInfo/browser_getProcessInfo.js new file mode 100644 index 0000000000..fb491e248f --- /dev/null +++ b/remote/cdp/test/browser/systemInfo/browser_getProcessInfo.js @@ -0,0 +1,78 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task( + async function getProcessInfoDetails({ client }) { + const { SystemInfo } = client; + + const processInfo = await SystemInfo.getProcessInfo(); + assertProcesses(processInfo); + }, + { createTab: false } +); + +add_task( + async function getProcessInfoMultipleTabs({ client }) { + const { SystemInfo, Target } = client; + + const { newTab: newTab1 } = await openTab(Target); + const { newTab: newTab2 } = await openTab(Target); + const { newTab: newTab3 } = await openTab(Target); + const { newTab: newTab4 } = await openTab(Target); + + const processInfo = await SystemInfo.getProcessInfo(); + assertProcesses(processInfo, [newTab1, newTab2, newTab3, newTab4]); + }, + { createTab: false } +); + +add_task( + async function getProcessInfoMultipleWindows({ client }) { + const { SystemInfo, Target } = client; + + const { newWindow: newWindow1 } = await openWindow(Target); + const { newWindow: newWindow2 } = await openWindow(Target); + + const processInfo = await SystemInfo.getProcessInfo(); + assertProcesses(processInfo, [ + ...newWindow1.gBrowser.tabs, + ...newWindow2.gBrowser.tabs, + ]); + + await BrowserTestUtils.closeWindow(newWindow1); + await BrowserTestUtils.closeWindow(newWindow2); + }, + { createTab: false } +); + +function assertProcesses(processInfo, tabs) { + ok(Array.isArray(processInfo), "Process info is an array"); + + for (const info of processInfo) { + ok(typeof info.id === "number", "Info has a numeric id"); + ok(typeof info.type === "string", "Info has a string type"); + ok(typeof info.cpuTime === "number", "Info has a numeric cpuTime"); + } + + const getByType = type => processInfo.filter(info => info.type === type); + + is( + getByType("browser").length, + 1, + "Got expected amount of browser processes" + ); + ok(!!getByType("renderer").length, "Got at least one renderer process"); + + if (tabs) { + const rendererPids = new Set( + processInfo.filter(info => info.type === "renderer").map(info => info.id) + ); + + for (const tab of tabs) { + const pid = tab.linkedBrowser.browsingContext.currentWindowGlobal.osPid; + ok(rendererPids.has(pid), `Found process info for pid (${pid})`); + } + } +} diff --git a/remote/cdp/test/browser/systemInfo/head.js b/remote/cdp/test/browser/systemInfo/head.js new file mode 100644 index 0000000000..1a1c90fbf6 --- /dev/null +++ b/remote/cdp/test/browser/systemInfo/head.js @@ -0,0 +1,9 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/remote/cdp/test/browser/head.js", + this +); |