summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/browser_subframesPreferUsed.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/ipc/tests/browser_subframesPreferUsed.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/ipc/tests/browser_subframesPreferUsed.js')
-rw-r--r--dom/ipc/tests/browser_subframesPreferUsed.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/ipc/tests/browser_subframesPreferUsed.js b/dom/ipc/tests/browser_subframesPreferUsed.js
new file mode 100644
index 0000000000..f2f9ed2593
--- /dev/null
+++ b/dom/ipc/tests/browser_subframesPreferUsed.js
@@ -0,0 +1,82 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+ok(
+ Services.appinfo.fissionAutostart,
+ "this test requires fission to function!"
+);
+
+function documentURL(origin, html) {
+ let params = new URLSearchParams();
+ params.append("html", html.trim());
+ return `${origin}/document-builder.sjs?${params.toString()}`;
+}
+
+async function singleTest(preferUsed) {
+ info(`running test with preferUsed=${preferUsed}`);
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["dom.ipc.processCount.webIsolated", 4],
+ ["browser.tabs.remote.subframesPreferUsed", preferUsed],
+ ],
+ });
+
+ const TEST_URL = documentURL(
+ "https://example.com",
+ `<iframe src=${JSON.stringify(
+ documentURL("https://example.org", `<h1>iframe</h1>`)
+ )}></iframe>`
+ );
+
+ await BrowserTestUtils.withNewTab(TEST_URL, async browser1 => {
+ is(browser1.browsingContext.children.length, 1);
+ let topProc1 = browser1.browsingContext.currentWindowGlobal.domProcess;
+ let frameProc1 =
+ browser1.browsingContext.children[0].currentWindowGlobal.domProcess;
+ isnot(
+ topProc1.childID,
+ frameProc1.childID,
+ "the frame should be in a separate process"
+ );
+
+ await BrowserTestUtils.withNewTab(TEST_URL, async browser2 => {
+ is(browser2.browsingContext.children.length, 1);
+ let topProc2 = browser2.browsingContext.currentWindowGlobal.domProcess;
+ let frameProc2 =
+ browser2.browsingContext.children[0].currentWindowGlobal.domProcess;
+ isnot(
+ topProc2.childID,
+ frameProc2.childID,
+ "the frame should be in a separate process"
+ );
+
+ // Compare processes used for the two tabs.
+ isnot(
+ topProc1.childID,
+ topProc2.childID,
+ "the toplevel windows should be loaded in separate processes"
+ );
+ if (preferUsed) {
+ is(
+ frameProc1.childID,
+ frameProc2.childID,
+ "the iframes should load in the same process with subframesPreferUsed"
+ );
+ } else {
+ isnot(
+ frameProc1.childID,
+ frameProc2.childID,
+ "the iframes should load in different processes without subframesPreferUsed"
+ );
+ }
+ });
+ });
+}
+
+add_task(async function test_preferUsed() {
+ await singleTest(true);
+});
+
+add_task(async function test_noPreferUsed() {
+ await singleTest(false);
+});