diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/base/test/test_embed_xorigin_document.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_embed_xorigin_document.html')
-rw-r--r-- | dom/base/test/test_embed_xorigin_document.html | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/dom/base/test/test_embed_xorigin_document.html b/dom/base/test/test_embed_xorigin_document.html new file mode 100644 index 0000000000..3075f1897b --- /dev/null +++ b/dom/base/test/test_embed_xorigin_document.html @@ -0,0 +1,103 @@ +<!DOCTYPE HTML> +<html> +<head> +<title>test for embedding a cross-origin document</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> + + + +<script> +// Get the path of the current test, without hostname or filename. +const testPath = window.location.href.replace("http://mochi.test:8888", ""); +const testDir = testPath.substring(0, testPath.lastIndexOf('/') + 1); +const embedHasBrowsingContext = SpecialPowers.getBoolPref("browser.opaqueResponseBlocking.syntheticBrowsingContext", false); +const imageTypeORB = embedHasBrowsingContext + ? SpecialPowers.Ci.nsIObjectLoadingContent.TYPE_DOCUMENT + : SpecialPowers.Ci.nsIObjectLoadingContent.TYPE_IMAGE; + +const imageTypeStringORB = embedHasBrowsingContext ? "document" : "image"; + +add_task(async function() { + // FIXME: Remove when bug 1658342 is fixed + await SpecialPowers.pushPrefEnv({ + set: [["fission.remoteObjectEmbed", true]], + }); + + info("Loading image in embed"); + let embed = document.createElement("embed"); + document.body.appendChild(embed); + + info("x-site image load from element"); + embed.setAttribute("src", "http://example.com" + testDir + "green.png"); + await new Promise(resolve => embed.addEventListener("load", resolve, { once: true })); + is( + SpecialPowers.wrap(embed).displayedType, + imageTypeORB, + `image load should have ${imageTypeStringORB} type` + ); + + if (!embedHasBrowsingContext) { + ok(!SpecialPowers.wrap(embed).frameLoader, "should not have frameloader"); + ok(!SpecialPowers.wrap(embed).browsingContext, "should not have bc"); + } else { + ok(SpecialPowers.wrap(embed).frameLoader, "should have frameloader"); + ok(SpecialPowers.wrap(embed).browsingContext, "should have bc"); + } + + info("x-site document load from element"); + embed.setAttribute("src", "http://example.com" + testDir + "file_empty.html"); + await new Promise(resolve => embed.addEventListener("load", resolve, { once: true })); + is( + SpecialPowers.wrap(embed).displayedType, + SpecialPowers.Ci.nsIObjectLoadingContent.TYPE_DOCUMENT, + "document load should have document type" + ); + ok(SpecialPowers.wrap(embed).frameLoader, "should have frameloader"); + ok(SpecialPowers.wrap(embed).browsingContext, "should have bc"); + + info("load x-site document in iframe & compare processes"); + let iframe = document.createElement("iframe"); + iframe.setAttribute("src", "http://example.com" + testDir + "file_empty.html"); + document.body.appendChild(iframe); + await new Promise(resolve => iframe.addEventListener("load", resolve, { once: true })); + + let embedRemoteType = await SpecialPowers.spawn(embed, [], () => Services.appinfo.remoteType); + let iframeRemoteType = await SpecialPowers.spawn(iframe, [], () => Services.appinfo.remoteType); + is(iframeRemoteType, embedRemoteType, "remote types should match"); + + info("x-site image load from docshell"); + SpecialPowers.spawn(embed, ["http://example.com" + testDir + "green.png"], uri => { + content.location.href = uri; + }) + await new Promise(resolve => embed.addEventListener("load", resolve, { once: true })); + is( + SpecialPowers.wrap(embed).displayedType, + SpecialPowers.Ci.nsIObjectLoadingContent.TYPE_DOCUMENT, + "image load via location should have document type" + ); + ok(SpecialPowers.wrap(embed).frameLoader, "should have frameloader"); + ok(SpecialPowers.wrap(embed).browsingContext, "should have bc"); + + info("x-site image load from element"); + embed.setAttribute("src", "http://example.com" + testDir + "green.png"); + await new Promise(resolve => embed.addEventListener("load", resolve, { once: true })); + is( + SpecialPowers.wrap(embed).displayedType, + imageTypeORB, + `image load should have ${imageTypeStringORB} type` + ); + + if (!embedHasBrowsingContext) { + ok(!SpecialPowers.wrap(embed).frameLoader, "should not have frameloader"); + ok(!SpecialPowers.wrap(embed).browsingContext, "should not have bc"); + } else { + ok(SpecialPowers.wrap(embed).frameLoader, "should have frameloader"); + ok(SpecialPowers.wrap(embed).browsingContext, "should have bc"); + } +}); +</script> +</body> +</html> |