Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<html>
<head>
<title>focus() from next tick before iframe loaded same site</title>
</head>
<body>
<script>
var pendingTimeout = false;
window.onmessage = function(e) {
if (e.data == "tick") {
iframe.focus();
if (document.activeElement != iframe) {
if (pendingTimeout) {
clearTimeout(pendingTimeout);
}
pendingTimeout = true;
opener.postMessage("FAIL activeElement", "*");
}
return;
}
if (e.data == "onload") {
if (pendingTimeout) {
return;
}
pendingTimeout = opener.step_timeout(function() {
opener.postMessage("FAIL missing onfocus", "*");
}, 2000);
return;
}
if (pendingTimeout) {
clearTimeout(pendingTimeout);
}
pendingTimeout = true;
if (e.data == "onfocus") {
// Test not upstreamed, because this even is a Firefoxism
opener.postMessage("PASS", "*");
return;
}
opener.postMessage("FAIL " + e.data, "*");
}
var iframe = document.createElement("iframe");
iframe.src = "focus-next-tick-before-iframe-loaded-same-site-inner.html";
document.body.appendChild(iframe);
window.postMessage("tick", "*");
</script>
</body>
</html>