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 /js/xpconnect/tests/mochitest/test_bug916945.html | |
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 'js/xpconnect/tests/mochitest/test_bug916945.html')
-rw-r--r-- | js/xpconnect/tests/mochitest/test_bug916945.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/js/xpconnect/tests/mochitest/test_bug916945.html b/js/xpconnect/tests/mochitest/test_bug916945.html new file mode 100644 index 0000000000..4e481563fc --- /dev/null +++ b/js/xpconnect/tests/mochitest/test_bug916945.html @@ -0,0 +1,78 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=916945 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 916945</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + + /** Test for Bug 916945 **/ + SimpleTest.waitForExplicitFinish(); + + var gLoadCount = 0; + function loaded() { + if (++gLoadCount == 2) + go(); + } + async function go() { + // Both same-origin and cross-origin names should be visible if they're set + // on the iframe element. + ok('winA' in window, "same-origin named access works"); + ok(winA instanceof Window, "same-origin named access works"); + ok('winB' in window, "cross-origin named access works when iframe name matches"); + ok(winB instanceof Window, "cross-origin named access works when iframe name matches"); + + // Setting the 'name' attribute should propagate to the docshell. + var ifrB = document.getElementById('ifrB'); + await SpecialPowers.spawn(ifrB, [], () => { + Assert.equal(this.content.name, 'winB', + 'initial attribute value propagates to the docshell'); + }); + + ifrB.setAttribute('name', 'foo'); + await SpecialPowers.spawn(ifrB, [], () => { + Assert.equal(this.content.name, 'foo', + 'attribute sets propagate to the docshell'); + }); + ok('foo' in window, "names are dynamic if updated via setAttribute"); + ok(foo instanceof Window, "names are dynamic if updated via setAttribute"); + + // Setting window.name on the subframe should not propagate to the attribute. + await SpecialPowers.spawn(ifrB, [], () => { + this.content.name = "bar"; + }); + is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute'); + + // When the frame element attribute and docshell name don't match, nothing is returned. + ok(!('foo' in window), "frame element name not resolved if it doesn't match the docshell"); + ok(!('bar' in window), "docshell name not resolved if it doesn't match the frame element"); + + // This shouldn't assert. + function listener() { + document.body.appendChild(ifrA); + ifrA.name = ""; + } + ifrA.addEventListener("DOMNodeInserted", listener, {once: true}); + document.body.appendChild(ifrA); + + SimpleTest.finish(); + } + + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=916945">Mozilla Bug 916945</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<iframe id="ifrA" name="winA" onload="loaded();" src="file_empty.html"></iframe> +<iframe id="ifrB" name="winB" onload="loaded();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe> +<pre id="test"> +</pre> +</body> +</html> |