test_bug478438.html (1864B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=478438 5 --> 6 <head> 7 <title>Test for Bug 478438</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 <script type="application/javascript"> 11 function fail(s, e) { ok(false, s + e) } 12 function pass(s, e) { ok(true, s) } 13 (pass.opposite = fail).opposite = pass; 14 15 function test() { 16 if (test.calledAlready) 17 return; 18 test.calledAlready = true; 19 20 var iwin = document.getElementById("f").contentWindow; 21 22 function testOne(fn, onAllow, infinitive) { 23 try { fn(); onAllow("able " + infinitive, "") } 24 catch (e) { onAllow.opposite("unable " + infinitive, ": " + e) } 25 } 26 27 testOne(() => iwin.focus, pass, 28 "to resolve/get allAccess property iwin.focus"); 29 30 testOne(() => iwin.focus(), pass, 31 "to call allAccess method iwin.focus"); 32 33 testOne(() => iwin.alert, fail, 34 "to resolve/get restricted property iwin.alert"); 35 36 testOne(() => iwin.alert(), fail, 37 "to call restricted method iwin.alert"); 38 39 testOne(() => iwin.location.toString(), fail, 40 "to call restricted method iwin.location.toString"); 41 42 testOne(function() { iwin.location = "http://example.org" }, pass, 43 "to set writable property iwin.location"); 44 45 SimpleTest.finish(); 46 } 47 </script> 48 </head> 49 <body> 50 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478438">Mozilla Bug 478438</a> 51 <p id="display"></p> 52 <div id="content"> 53 <iframe id="f" src="http://example.com" onload="test()"></iframe> 54 </div> 55 <pre id="test"> 56 <script type="application/javascript"> 57 58 /** Test for Bug 478438 **/ 59 60 SimpleTest.waitForExplicitFinish(); 61 62 </script> 63 </pre> 64 </body> 65 </html>