test_iframe_sandbox_workers.html (2270B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=341604 5 Implement HTML5 sandbox attribute for IFRAMEs - tests for workers 6 --> 7 <head> 8 <meta charset="utf-8"> 9 <title>Test for Bug 341604</title> 10 <script src="/tests/SimpleTest/SimpleTest.js"></script> 11 <script src="/tests/SimpleTest/EventUtils.js"></script> 12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 13 </head> 14 <script type="application/javascript"> 15 /** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs - test for workers */ 16 17 SimpleTest.waitForExplicitFinish(); 18 19 // a postMessage handler that is used by sandboxed iframes without 20 // 'allow-same-origin' to communicate pass/fail back to this main page. 21 // it expects to be called with an object like {ok: true/false, desc: 22 // <description of the test> which it then forwards to ok() 23 window.addEventListener("message", receiveMessage); 24 25 function receiveMessage(event) 26 { 27 ok_wrapper(event.data.ok, event.data.desc); 28 } 29 30 var completedTests = 0; 31 var passedTests = 0; 32 33 function ok_wrapper(result, desc) { 34 ok(result, desc); 35 36 completedTests++; 37 38 if (result) { 39 passedTests++; 40 } 41 42 if (completedTests == 3) { 43 is(passedTests, 3, "There are 3 worker tests that should pass"); 44 SimpleTest.finish(); 45 } 46 } 47 48 function doTest() { 49 // passes if good 50 // 1) test that a worker in a sandboxed iframe with 'allow-scripts' can be loaded 51 // from a data: URI 52 // (done by file_iframe_sandbox_g_if1.html) 53 54 // passes if good 55 // 2) test that a worker in a sandboxed iframe with 'allow-scripts' can be loaded 56 // from a blob URI created by the sandboxed document itself 57 // (done by file_iframe_sandbox_g_if1.html) 58 59 // passes if good 60 // 3) test that a worker in a sandboxed iframe with 'allow-scripts' without 61 // 'allow-same-origin' cannot load a script via a relative URI 62 // (done by file_iframe_sandbox_g_if1.html) 63 } 64 65 addLoadEvent(doTest); 66 </script> 67 <body> 68 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs 69 <p id="display"></p> 70 <div id="content"> 71 <iframe sandbox="allow-scripts" id="if_1" src="file_iframe_sandbox_g_if1.html" height="10" width="10"></iframe> 72 </div> 73 </body> 74 </html>