4 https://bugzilla.mozilla.org/show_bug.cgi?id=916945
8 <title>Test for Bug
916945</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script type=
"application/javascript">
13 /** Test for Bug
916945 **/
14 SimpleTest.waitForExplicitFinish();
18 if (++gLoadCount ==
2)
22 // Both same-origin and cross-origin names should be visible if they're set
23 // on the iframe element.
24 ok('winA' in window,
"same-origin named access works");
25 ok(winA instanceof winA.Window,
"same-origin named access works");
26 ok('winB' in window,
"cross-origin named access works when iframe name matches");
27 is(winB.parent, window,
"cross-origin named access works when iframe name matches");
29 // Setting the 'name' attribute should propagate to the docshell.
30 var ifrB = document.getElementById('ifrB');
31 await SpecialPowers.spawn(ifrB, [], () =
> {
32 Assert.equal(this.content.name, 'winB',
33 'initial attribute value propagates to the docshell');
36 ifrB.setAttribute('name', 'foo');
37 await SpecialPowers.spawn(ifrB, [], () =
> {
38 Assert.equal(this.content.name, 'foo',
39 'attribute sets propagate to the docshell');
41 ok('foo' in window,
"names are dynamic if updated via setAttribute");
42 is(foo.parent, window,
"names are dynamic if updated via setAttribute");
44 // Setting window.name on the subframe should not propagate to the attribute.
45 await SpecialPowers.spawn(ifrB, [], () =
> {
46 this.content.name =
"bar";
48 is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute');
50 // When the frame element attribute and docshell name don't match, nothing is returned.
51 ok(!('foo' in window),
"frame element name not resolved if it doesn't match the docshell");
52 ok(!('bar' in window),
"docshell name not resolved if it doesn't match the frame element");
54 // This shouldn't assert.
56 document.body.appendChild(ifrA);
59 ifrA.addEventListener(
"DOMNodeInserted", listener, {once: true});
60 document.body.appendChild(ifrA);
68 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=916945">Mozilla Bug
916945</a>
70 <div id=
"content" style=
"display: none">
73 <iframe id=
"ifrA" name=
"winA" onload=
"loaded();" src=
"file_empty.html"></iframe>
74 <iframe id=
"ifrB" name=
"winB" onload=
"loaded();" src=
"http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>