OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script> | 4 <script> |
5 function startTest() | 5 function startTest() |
6 { | 6 { |
7 t = window.top; | 7 t = window.top; |
8 t.shouldBe("window", "self"); | 8 t.shouldBe("window", "self"); |
9 t.shouldBe("window", "frames"); | 9 t.shouldBe("window", "frames"); |
10 t.shouldBe("parent", "top"); | 10 t.shouldBe("parent", "top"); |
11 t.savedClosure = function() | 11 t.savedClosure = () => { |
| 12 // The normal shouldBeNull() helpers don't work well here, since they don't |
| 13 // eval in the right context. |
| 14 function shouldBeNull(value, name) |
12 { | 15 { |
13 // The normal shouldBeNull() helpers don't work well here, since they do
n't eval | 16 if (value === null) |
14 //in the right context. | 17 t.testPassed(name + " is null."); |
15 function testProperty(value, name) | 18 else |
16 { | 19 t.testFailed(name + " should be null. Was " + value); |
17 if (value === null) | 20 } |
18 t.testPassed(name + " is null."); | 21 function shouldBeNonNull(value, name) { |
19 else | 22 if (value != null) |
20 t.testFailed(name + " is not null!"); | 23 t.testPassed(name + " is non-null."); |
21 } | 24 else |
22 testProperty(window, "window"); | 25 t.testFailed(name + " should be non-null. Was " + value); |
23 testProperty(self, "self"); | 26 } |
24 testProperty(frames, "frames"); | 27 |
25 testProperty(parent, "parent"); | 28 // window, self and frames never be null. |
26 testProperty(top, "top"); | 29 // https://html.spec.whatwg.org/multipage/browsers.html#dom-window |
27 }; | 30 shouldBeNonNull(window, "window"); |
28 location = 'data:text/html,<body>Testing...</body>'; | 31 shouldBeNonNull(self, "self"); |
| 32 shouldBeNonNull(frames, "frames"); |
| 33 |
| 34 // top and parent are null if there is no browsing context with the |
| 35 // WindowProxy. |
| 36 // https://html.spec.whatwg.org/multipage/browsers.html#dom-top |
| 37 // https://html.spec.whatwg.org/multipage/browsers.html#dom-parent |
| 38 shouldBeNull(parent, "parent"); |
| 39 shouldBeNull(top, "top"); |
| 40 }; |
| 41 location = 'data:text/html,<body>Testing...</body>'; |
29 } | 42 } |
30 </script> | 43 </script> |
31 </head> | 44 </head> |
32 <body onload="startTest()"> | 45 <body onload="startTest()"> |
33 </body> | 46 </body> |
34 </html> | 47 </html> |
OLD | NEW |