focus-before-iframe-loaded-same-site-outer.html (1087B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>focus() before iframe loaded same site</title> 5 </head> 6 <body> 7 <script> 8 var pendingTimeout = false; 9 window.onmessage = function(e) { 10 if (e.data == "onload") { 11 if (pendingTimeout) { 12 return; 13 } 14 pendingTimeout = opener.step_timeout(function() { 15 opener.postMessage("FAIL missing onfocus", "*"); 16 }, 2000); 17 return; 18 } 19 if (pendingTimeout) { 20 clearTimeout(pendingTimeout); 21 } 22 pendingTimeout = true; 23 if (e.data == "onfocus") { 24 // Test not upstreamed, because this even is a Firefoxism 25 // https://github.com/whatwg/html/issues/6209 26 opener.postMessage("PASS", "*"); 27 return; 28 } 29 opener.postMessage("FAIL " + e.data, "*"); 30 } 31 32 var iframe = document.createElement("iframe"); 33 iframe.src = "focus-before-iframe-loaded-same-site-inner.html"; 34 document.body.appendChild(iframe); 35 iframe.focus(); 36 if (document.activeElement != iframe) { 37 pendingTimeout = true; 38 opener.postMessage("FAIL activeElement", "*"); 39 } 40 </script> 41 </body> 42 </html>