file_iframe_sandbox_d_if23.html (2030B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test for Bug 838692</title> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 10 <script type="application/javascript"> 11 var test27Context = "Test 27: navigate opened window by name with anchor: "; 12 var test28Context = "Test 28: navigate opened window by name with window.open(): "; 13 14 var windowsToClose = new Array(); 15 16 function closeWindows() { 17 for (var i = 0; i < windowsToClose.length; i++) { 18 windowsToClose[i].close(); 19 } 20 } 21 22 // Add message listener to forward messages on to parent 23 window.addEventListener("message", receiveMessage); 24 25 function receiveMessage(event) { 26 switch (event.data.type) { 27 case "closeWindows": 28 closeWindows(); 29 break; 30 default: 31 window.parent.postMessage(event.data, "*"); 32 } 33 } 34 35 function doTest() { 36 try { 37 windowsToClose.push(window.open("about:blank", "test27window")); 38 var test27Anchor = document.getElementById("test27Anchor"); 39 test27Anchor.href = "file_iframe_sandbox_window_navigation_pass.html?" + escape(test27Context); 40 sendMouseEvent({type:"click"}, "test27Anchor"); 41 window.parent.postMessage({type: "attempted"}, "*"); 42 } catch(error) { 43 window.parent.postMessage({ok: false, desc: test27Context + "error thrown during window.open(): " + error}, "*"); 44 } 45 46 try { 47 windowsToClose.push(window.open("about:blank", "test28window")); 48 window.open("file_iframe_sandbox_window_navigation_pass.html?" + escape(test28Context), "test28window"); 49 window.parent.postMessage({type: "attempted"}, "*"); 50 } catch(error) { 51 window.parent.postMessage({ok: false, desc: test28Context + "error thrown during window.open(): " + error}, "*"); 52 } 53 } 54 </script> 55 56 <body onload="doTest()"> 57 I am sandboxed with 'allow-scripts allow-popups' 58 59 <a id="test27Anchor" target="test27window">Test 27 anchor</a> 60 </body> 61 </html>