iframe-focuses-parent-different-site-outer.sub.html (944B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>iframe focuses parent different site outer</title> 6 </head> 7 <body> 8 <iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-focuses-parent-different-site-inner.html"></iframe> 9 <script> 10 var w = null; 11 var focusDisallowed = false; 12 var failed = false; 13 window.onmessage = function(e) { 14 if (failed) { 15 return; 16 } 17 if (e.data == "ready") { 18 focusDisallowed = true; 19 document.getElementsByTagName("iframe")[0].contentWindow.postMessage("focus", "*"); 20 return; 21 } 22 focusDisallowed = false; 23 if (w) { 24 w.close(); 25 w = null; 26 } 27 opener.postMessage(failed ? "FAIL" : "PASS", "*"); 28 } 29 window.onload = function() { 30 w = window.open("iframe-focuses-parent-different-site-other.html"); 31 } 32 document.body.onfocus = function() { 33 if (focusDisallowed) { 34 failed = true; 35 } 36 } 37 </script> 38 </body> 39 </html>