diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/outOfProcess/browser_basic_outofprocess.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/outOfProcess/browser_basic_outofprocess.js | 149 |
1 files changed, 149 insertions, 0 deletions
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 = "<p>Text</p>"; + + 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 "<p>Text " + ++counter + "</p>"; + } + ); + + 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 "<p>Text " + c + "</p>"; + } + } + await verifyBaseFrameStructure( + browsingContexts, + "function", + getExpectedHTML() + ); + + BrowserTestUtils.removeTab(tab); +}); |