5 https://bugzilla.mozilla.org/show_bug.cgi?id=823228
9 <title>Test for Bug
823228</title>
10 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=823228">Mozilla Bug
823228</a>
16 <div id=
"content" style=
"display: none">
17 <iframe name=
"x" id=
"x"></iframe>
18 <iframe name=
"y" id=
"y"></iframe>
22 <script type=
"application/javascript">
24 /** Test for Bug
823228 **/
25 is(window, window.frames,
"These better be equal");
26 ok(
"0" in window,
"We have a subframe");
27 ok(
"1" in window,
"We have two subframes");
28 ok(!(
"2" in window),
"But we don't have three subframes");
29 window[
2] =
"myString";
30 ok(!(
"2" in window),
"Should not be able to set indexed expando");
31 Object.getPrototypeOf(window)[
3] =
"Hey there";
32 ok(
"3" in window,
"Should be walking up the proto chain");
34 is(window[
0].name,
"x",
"First frame is x");
35 is(window[
1].name,
"y",
"Second frame is y");
36 is(window[
2], undefined,
"We should still not have our expando");
37 is(window[
3],
"Hey there",
"We should still have our prop on the proto chain");
42 is(x.contentWindow, window[
0],
"First frame should have correct window");
43 is(y.contentWindow, window[
1],
"Second frame should have correct window");
47 is(window[
1].name,
"y",
"Second frame is still y");
48 y.parentNode.removeChild(y);
49 ok(!(
"1" in window),
"We no longer have two subframes");
50 is(window[
1], undefined,
"We should not have a value here");
52 // defineProperty() hook test
53 x.parentNode.appendChild(y);
54 Object.defineProperty(window,
"1", { value:
"FAIL2", configurable: true,
56 y.parentNode.removeChild(y);
57 ok(!(
"1" in window),
"We no longer have two subframes, again");
58 is(window[
1], undefined,
"We should not have a value here either");
60 // More set() hook test
62 ok(!(
"1" in window),
"We shouldn't allow indexed expandos");
63 is(window[
1], undefined,
"We should not have a value for an indexed expando");
64 var desc = Object.getOwnPropertyDescriptor(window,
"1");
65 is(desc, undefined,
"We really really shouldn't have indexed expandos");
67 x.parentNode.appendChild(y);
68 is(window[
1], y.contentWindow,
"Second frame should now be visible");
69 desc = Object.getOwnPropertyDescriptor(window,
"1");
70 ok(desc.configurable,
"Subframe should be configurable");
71 ok(desc.enumerable,
"Subframe should be configurable");
72 ok(!desc.writable,
"Subframe should not be writable");
73 is(desc.value, y.contentWindow,
"Subframe should have correct value");
75 y.parentNode.removeChild(y);
76 is(window[
1], undefined,
"And now we should be back to no [1] property");
78 // And more defineProperty()
79 Object.defineProperty(window,
"1", { value:
"FAIL2", configurable: true,
81 ok(!(
"1" in window),
"Defining indexed properties really just shouldn't work");
82 is(window[
1], undefined,
"Defining past end of list should not work");
85 x.parentNode.appendChild(y);
87 var names = Object.getOwnPropertyNames(window);
88 is(names[
0],
"0",
"Must start with 0");
89 is(names[
1],
"1",
"Must continue with 1");
90 is(names.indexOf(
"2"), -
1,
"And 2, an attempted expando, should not be in there");
91 is(names.indexOf(
"3"), -
1,
"But no 3; that's on the proto");
94 for (var name in window) {
97 is(names[
0],
"0",
"Enumeration must start with 0");
98 is(names[
1],
"1",
"Enumeration must continue with 1");
99 is(names.indexOf(
"2"), -
1,
"Enumeration: but no expando 2");
100 isnot(names.indexOf(
"3"), -
1,
"Enumeration: and then 3, defined on the proto");
101 is(names.indexOf(
"4"), -
1,
"But no 4 around");
104 is(delete window[
1], false,
"Deleting supported index should return false");
105 is(window[
1], y.contentWindow,
"Shouldn't be able to delete a supported index");
106 y.parentNode.removeChild(y);
107 is(window[
1], undefined,
108 "And now we should have no property here");
109 is(delete window[
1], true,
"Deleting unsupported index should return true");
110 is(window[
1], undefined,
111 "And we shouldn't have things magically appear due to delete");