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 --- .../outOfProcess/browser_basic_outofprocess.js | 149 +++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 browser/base/content/test/outOfProcess/browser_basic_outofprocess.js (limited to 'browser/base/content/test/outOfProcess/browser_basic_outofprocess.js') diff --git a/browser/base/content/test/outOfProcess/browser_basic_outofprocess.js b/browser/base/content/test/outOfProcess/browser_basic_outofprocess.js new file mode 100644 index 0000000000..50914a286c --- /dev/null +++ b/browser/base/content/test/outOfProcess/browser_basic_outofprocess.js @@ -0,0 +1,149 @@ +/** + * Verify that the colors were set properly. This has the effect of + * verifying that the processes are assigned for child frames correctly. + */ +async function verifyBaseFrameStructure( + browsingContexts, + testname, + expectedHTML +) { + function checkColorAndText(bc, desc, expectedColor, expectedText) { + return SpecialPowers.spawn( + bc, + [expectedColor, expectedText, desc], + (expectedColorChild, expectedTextChild, descChild) => { + Assert.equal( + content.document.documentElement.style.backgroundColor, + expectedColorChild, + descChild + " color" + ); + Assert.equal( + content.document.getElementById("insertPoint").innerHTML, + expectedTextChild, + descChild + " text" + ); + } + ); + } + + let useOOPFrames = gFissionBrowser; + + is( + browsingContexts.length, + TOTAL_FRAME_COUNT, + "correct number of browsing contexts" + ); + await checkColorAndText( + browsingContexts[0], + testname + " base", + "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[1], + testname + " frame 1", + useOOPFrames ? "seashell" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[2], + testname + " frame 1-1", + useOOPFrames ? "seashell" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[3], + testname + " frame 2", + useOOPFrames ? "lightcyan" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[4], + testname + " frame 2-1", + useOOPFrames ? "seashell" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[5], + testname + " frame 2-2", + useOOPFrames ? "lightcyan" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[6], + testname + " frame 2-3", + useOOPFrames ? "palegreen" : "white", + expectedHTML.next().value + ); + await checkColorAndText( + browsingContexts[7], + testname + " frame 2-4", + "white", + expectedHTML.next().value + ); +} + +/** + * Test setting up all of the frames where a string of markup is passed + * to initChildFrames. + */ +add_task(async function test_subframes_string() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + OOP_BASE_PAGE_URI + ); + + const markup = "

Text

"; + + let browser = tab.linkedBrowser; + let browsingContexts = await initChildFrames(browser, markup); + + function* getExpectedHTML() { + for (let c = 1; c <= TOTAL_FRAME_COUNT; c++) { + yield markup; + } + ok(false, "Frame count does not match actual number of frames"); + } + await verifyBaseFrameStructure(browsingContexts, "string", getExpectedHTML()); + + BrowserTestUtils.removeTab(tab); +}); + +/** + * Test setting up all of the frames where a function that returns different markup + * is passed to initChildFrames. + */ +add_task(async function test_subframes_function() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + OOP_BASE_PAGE_URI + ); + let browser = tab.linkedBrowser; + + let counter = 0; + let browsingContexts = await initChildFrames( + browser, + function (browsingContext) { + return "

Text " + ++counter + "

"; + } + ); + + is( + counter, + TOTAL_FRAME_COUNT, + "insert HTML function called the correct number of times" + ); + + function* getExpectedHTML() { + for (let c = 1; c <= TOTAL_FRAME_COUNT; c++) { + yield "

Text " + c + "

"; + } + } + await verifyBaseFrameStructure( + browsingContexts, + "function", + getExpectedHTML() + ); + + BrowserTestUtils.removeTab(tab); +}); -- cgit v1.2.3