| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <body onload="test()"> | |
| 3 <div id='result'> | |
| 4 <p> | |
| 5 Test that the window and top attributes cannot be overwritten by var | |
| 6 declarations or accessors defined using __defineGetter__ and | |
| 7 __defineSetter__. Flash accesses top.location and window.location and | |
| 8 for security needs to see the actual location. | |
| 9 </p> | |
| 10 </div> | |
| 11 <iframe id="testFrame"></iframe> | |
| 12 <script> | |
| 13 if (window.layoutTestController) { | |
| 14 layoutTestController.dumpAsText(); | |
| 15 layoutTestController.waitUntilDone(); | |
| 16 } | |
| 17 | |
| 18 function notifyDone() { | |
| 19 if (window.layoutTestController) { | |
| 20 layoutTestController.notifyDone(); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 var resultDiv = document.getElementById("result"); | |
| 25 | |
| 26 function check(passed) { | |
| 27 if (passed) { | |
| 28 resultDiv.innerHTML += "PASS<br>"; | |
| 29 } else { | |
| 30 resultDiv.innerHTML += "FAIL<br>"; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 var overwrite = { location: 'ick' }; | |
| 35 | |
| 36 function failIfCalled() { check(false); } | |
| 37 | |
| 38 function testWindowAccessorOverwrite() { | |
| 39 __defineGetter__("window", failIfCalled); | |
| 40 window; | |
| 41 window.__defineGetter__("window", failIfCalled); | |
| 42 window.window; | |
| 43 this.__defineGetter__("window", failIfCalled); | |
| 44 this.window; | |
| 45 __defineSetter__("window", failIfCalled); | |
| 46 window = overwrite; | |
| 47 window.__defineSetter__("window", failIfCalled); | |
| 48 window.window = overwrite; | |
| 49 this.__defineSetter__("window", failIfCalled); | |
| 50 this.window = overwrite; | |
| 51 delete window; | |
| 52 __defineGetter__("window", failIfCalled); | |
| 53 window; | |
| 54 } | |
| 55 | |
| 56 function testTopAccessorOverwrite() { | |
| 57 __defineGetter__("top", failIfCalled); | |
| 58 top; | |
| 59 window.__defineGetter__("top", failIfCalled); | |
| 60 window.top; | |
| 61 this.__defineGetter__("top", failIfCalled); | |
| 62 this.top; | |
| 63 __defineSetter__("top", failIfCalled); | |
| 64 top = overwrite; | |
| 65 window.__defineSetter__("top", failIfCalled); | |
| 66 window.top = overwrite; | |
| 67 this.__defineSetter__("top", failIfCalled); | |
| 68 this.top = overwrite; | |
| 69 delete top; | |
| 70 __defineGetter__("top", failIfCalled); | |
| 71 top; | |
| 72 | |
| 73 } | |
| 74 | |
| 75 function testVarShadowing() { | |
| 76 testFrame.location = "resources/window-shadowing-inner.html"; | |
| 77 } | |
| 78 | |
| 79 function test() { | |
| 80 testWindowAccessorOverwrite(); | |
| 81 testTopAccessorOverwrite(); | |
| 82 testVarShadowing(); | |
| 83 } | |
| 84 </script> | |
| 85 </body> | |
| 86 </html> | |
| OLD | NEW |