summaryrefslogtreecommitdiffstats
path: root/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js')
-rw-r--r--toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js161
1 files changed, 161 insertions, 0 deletions
diff --git a/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
new file mode 100644
index 0000000000..3286227d37
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
@@ -0,0 +1,161 @@
+add_task(async function oopProcessSwap() {
+ const FILE = fileURL("dummy_page.html");
+ const WEB = httpURL("file_postmsg_parent.html");
+
+ let win = await BrowserTestUtils.openNewBrowserWindow({ fission: true });
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser: win.gBrowser, url: FILE },
+ async browser => {
+ is(browser.browsingContext.children.length, 0);
+
+ info("creating an in-process frame");
+ let frameId = await SpecialPowers.spawn(
+ browser,
+ [{ FILE }],
+ async ({ FILE }) => {
+ let iframe = content.document.createElement("iframe");
+ iframe.setAttribute("src", FILE);
+ content.document.body.appendChild(iframe);
+
+ // The nested URI should be same-process
+ ok(iframe.browsingContext.docShell, "Should be in-process");
+
+ return iframe.browsingContext.id;
+ }
+ );
+
+ is(browser.browsingContext.children.length, 1);
+
+ info("navigating to x-process frame");
+ let oopinfo = await SpecialPowers.spawn(
+ browser,
+ [{ WEB }],
+ async ({ WEB }) => {
+ let iframe = content.document.querySelector("iframe");
+
+ iframe.contentWindow.location = WEB;
+
+ let data = await new Promise(resolve => {
+ content.window.addEventListener(
+ "message",
+ function (evt) {
+ info("oop iframe loaded");
+ is(evt.source, iframe.contentWindow);
+ resolve(evt.data);
+ },
+ { once: true }
+ );
+ });
+
+ is(iframe.browsingContext.docShell, null, "Should be out-of-process");
+ is(
+ iframe.browsingContext.embedderElement,
+ iframe,
+ "correct embedder"
+ );
+
+ return {
+ location: data.location,
+ browsingContextId: iframe.browsingContext.id,
+ };
+ }
+ );
+
+ is(browser.browsingContext.children.length, 1);
+
+ if (Services.prefs.getBoolPref("fission.preserve_browsing_contexts")) {
+ is(
+ frameId,
+ oopinfo.browsingContextId,
+ `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`
+ );
+ }
+ is(oopinfo.location, WEB, "correct location");
+ }
+ );
+
+ await BrowserTestUtils.closeWindow(win);
+});
+
+add_task(async function oopOriginProcessSwap() {
+ const COM_DUMMY = httpURL("dummy_page.html", "https://example.com/");
+ const ORG_POSTMSG = httpURL(
+ "file_postmsg_parent.html",
+ "https://example.org/"
+ );
+
+ let win = await BrowserTestUtils.openNewBrowserWindow({ fission: true });
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser: win.gBrowser, url: COM_DUMMY },
+ async browser => {
+ is(browser.browsingContext.children.length, 0);
+
+ info("creating an in-process frame");
+ let frameId = await SpecialPowers.spawn(
+ browser,
+ [{ COM_DUMMY }],
+ async ({ COM_DUMMY }) => {
+ let iframe = content.document.createElement("iframe");
+ iframe.setAttribute("src", COM_DUMMY);
+ content.document.body.appendChild(iframe);
+
+ // The nested URI should be same-process
+ ok(iframe.browsingContext.docShell, "Should be in-process");
+
+ return iframe.browsingContext.id;
+ }
+ );
+
+ is(browser.browsingContext.children.length, 1);
+
+ info("navigating to x-process frame");
+ let oopinfo = await SpecialPowers.spawn(
+ browser,
+ [{ ORG_POSTMSG }],
+ async ({ ORG_POSTMSG }) => {
+ let iframe = content.document.querySelector("iframe");
+
+ iframe.contentWindow.location = ORG_POSTMSG;
+
+ let data = await new Promise(resolve => {
+ content.window.addEventListener(
+ "message",
+ function (evt) {
+ info("oop iframe loaded");
+ is(evt.source, iframe.contentWindow);
+ resolve(evt.data);
+ },
+ { once: true }
+ );
+ });
+
+ is(iframe.browsingContext.docShell, null, "Should be out-of-process");
+ is(
+ iframe.browsingContext.embedderElement,
+ iframe,
+ "correct embedder"
+ );
+
+ return {
+ location: data.location,
+ browsingContextId: iframe.browsingContext.id,
+ };
+ }
+ );
+
+ is(browser.browsingContext.children.length, 1);
+ if (Services.prefs.getBoolPref("fission.preserve_browsing_contexts")) {
+ is(
+ frameId,
+ oopinfo.browsingContextId,
+ `BrowsingContext should not have changed (${frameId} != ${oopinfo.browsingContextId})`
+ );
+ }
+ is(oopinfo.location, ORG_POSTMSG, "correct location");
+ }
+ );
+
+ await BrowserTestUtils.closeWindow(win);
+});