From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tests/browser/browser_oopProcessSwap.js | 161 +++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js (limited to 'toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js') 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); +}); -- cgit v1.2.3