blob: 3bed7477fc1cdb030cbb6c97f65d9740ab3dbcdf [file] [log] [blame]
<script>
var failed = false;
function runTest() {
window.onfocus = windowFocused;
window.onblur = windowBlurred;
if (window.layoutTestController) {
window.layoutTestController.dumpAsText();
window.layoutTestController.setMainFrameIsFirstResponder(true);
window.layoutTestController.setWindowIsKey(false);
window.layoutTestController.setWindowIsKey(true);
window.layoutTestController.setWindowIsKey(false);
}
}
function log(message) {
var console = document.getElementById("console");
var li = document.createElement("li");
var text = document.createTextNode(message);
console.appendChild(li);
li.appendChild(text);
}
function windowFocused() {
log("Window was focused");
}
function windowBlurred() {
log("Window was blurred");
}
</script>
<body>
This tests window.onFocus and window.onBlur handlers. It uses the layoutTestControllers ability to mimic bringing the window to the front and pushing it to the back.
<p><b>It is not intended to be run interactively:</b> when you run it interactively, you should see 'Window was blurred' and 'Window was focused' messages as you push the window to the back and bring it to the front, respectively.</p>
<ul id="console"></ul>
<script>runTest();</script>
</body>