diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/base/test/browser_bug902350.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/browser_bug902350.js')
-rw-r--r-- | dom/base/test/browser_bug902350.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/dom/base/test/browser_bug902350.js b/dom/base/test/browser_bug902350.js new file mode 100644 index 0000000000..141dce5711 --- /dev/null +++ b/dom/base/test/browser_bug902350.js @@ -0,0 +1,56 @@ +/* + * Mixed Content Block frame navigates for target="_top" - Test for Bug 902350 + */ + +add_task(async function mixed_content_block_for_target_top_test() { + const PREF_ACTIVE = "security.mixed_content.block_active_content"; + const httpsTestRoot = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" + ); + + await SpecialPowers.pushPrefEnv({ set: [[PREF_ACTIVE, true]] }); + + let newTab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + waitForLoad: true, + }); + let testBrowser = newTab.linkedBrowser; + + var url = httpsTestRoot + "file_bug902350.html"; + var frameUrl = httpsTestRoot + "file_bug902350_frame.html"; + let loadPromise = BrowserTestUtils.browserLoaded(testBrowser, false, url); + let frameLoadPromise = BrowserTestUtils.browserLoaded( + testBrowser, + true, + frameUrl + ); + BrowserTestUtils.loadURI(testBrowser, url); + await loadPromise; + await frameLoadPromise; + + // Find the iframe and click the link in it. + let insecureUrl = "http://example.com/"; + let insecureLoadPromise = BrowserTestUtils.browserLoaded( + testBrowser, + false, + insecureUrl + ); + SpecialPowers.spawn(testBrowser, [], function() { + var frame = content.document.getElementById("testing_frame"); + var topTarget = frame.contentWindow.document.getElementById("topTarget"); + topTarget.click(); + }); + + // Navigating to insecure domain through target='_top' should succeed. + await insecureLoadPromise; + + // The link click should not invoke the Mixed Content Blocker. + let { gIdentityHandler } = testBrowser.ownerGlobal; + ok( + !gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"), + "Mixed Content Doorhanger did not appear when trying to navigate top" + ); + + BrowserTestUtils.removeTab(newTab); +}); |