test_bug797909.html (1688B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=797909 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 797909</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body onload="runTest()"> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=797909">Mozilla Bug 797909</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 17 </div> 18 <pre id="test"> 19 <script type="application/javascript"> 20 /** Test for Bug 797909 */ 21 22 SimpleTest.waitForExplicitFinish(); 23 24 function runTest() { 25 var iframe = document.getElementById("ifr"); 26 try { 27 iframe.contentWindow.document; 28 ok(false, "Should have thrown an exception"); 29 } catch (ex) { 30 ok(true, "Got an exception"); 31 } 32 33 iframe = document.createElement("iframe"); 34 // set sandbox attribute 35 iframe.sandbox = "allow-scripts"; 36 // and then insert into the doc 37 document.body.appendChild(iframe); 38 39 try { 40 iframe.contentWindow.document; 41 ok(false, "Should have thrown an exception"); 42 } catch (ex) { 43 ok(true, "Got an exception"); 44 } 45 46 iframe = document.createElement("iframe"); 47 // set sandbox attribute 48 iframe.sandbox = "allow-same-origin"; 49 // and then insert into the doc 50 document.body.appendChild(iframe); 51 52 try { 53 iframe.contentWindow.document; 54 ok(true, "Shouldn't have thrown an exception"); 55 } catch (ex) { 56 ok(false, "Got an unexpected exception"); 57 } 58 59 SimpleTest.finish(); 60 } 61 62 </script> 63 </pre> 64 <iframe id="ifr" sandbox = "allow-scripts"></iframe> 65 </body> 66 </html>