diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/pageStyle/browser_disable_author_style_oop.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/pageStyle/browser_disable_author_style_oop.js')
-rw-r--r-- | browser/base/content/test/pageStyle/browser_disable_author_style_oop.js | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/browser/base/content/test/pageStyle/browser_disable_author_style_oop.js b/browser/base/content/test/pageStyle/browser_disable_author_style_oop.js new file mode 100644 index 0000000000..f89e08a220 --- /dev/null +++ b/browser/base/content/test/pageStyle/browser_disable_author_style_oop.js @@ -0,0 +1,100 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +async function getColor(aSpawnTarget) { + return SpecialPowers.spawn(aSpawnTarget, [], function () { + return content.document.defaultView.getComputedStyle( + content.document.querySelector("p") + ).color; + }); +} + +async function insertIFrame() { + let bc = gBrowser.selectedBrowser.browsingContext; + let len = bc.children.length; + + const kURL = + WEB_ROOT.replace("example.com", "example.net") + "page_style.html"; + await SpecialPowers.spawn(gBrowser.selectedBrowser, [kURL], function (url) { + return new Promise(function (resolve) { + let e = content.document.createElement("iframe"); + e.src = url; + e.onload = () => resolve(); + content.document.body.append(e); + }); + }); + + // Wait for the new frame to get a pres shell and be styled. + await BrowserTestUtils.waitForCondition(async function () { + return ( + bc.children.length == len + 1 && (await getColor(bc.children[len])) != "" + ); + }); +} + +// Test that inserting an iframe with a URL that is loaded OOP with Fission +// enabled correctly matches the tab's author style disabled state. +add_task(async function test_disable_style() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + WEB_ROOT + "page_style.html", + /* waitForLoad = */ true + ); + + let bc = gBrowser.selectedBrowser.browsingContext; + + await insertIFrame(); + + is( + await getColor(bc), + "rgb(0, 0, 255)", + "parent color before disabling style" + ); + is( + await getColor(bc.children[0]), + "rgb(0, 0, 255)", + "first child color before disabling style" + ); + + gPageStyleMenu.disableStyle(); + + is(await getColor(bc), "rgb(0, 0, 0)", "parent color after disabling style"); + is( + await getColor(bc.children[0]), + "rgb(0, 0, 0)", + "first child color after disabling style" + ); + + await insertIFrame(); + + is( + await getColor(bc.children[1]), + "rgb(0, 0, 0)", + "second child color after disabling style" + ); + + await BrowserTestUtils.reloadTab(tab, true); + + // Check the menu: + let { menupopup } = document.getElementById("pageStyleMenu"); + gPageStyleMenu.fillPopup(menupopup); + Assert.equal( + menupopup.querySelector("menuitem[checked='true']").dataset.l10nId, + "menu-view-page-style-no-style", + "No style menu should be checked." + ); + + // check the page content still has a disabled author style: + Assert.ok( + await SpecialPowers.spawn( + tab.linkedBrowser, + [], + () => content.docShell.contentViewer.authorStyleDisabled + ), + "Author style should still be disabled." + ); + + BrowserTestUtils.removeTab(tab); +}); |