blob: 533c6e0841c267065d78a09a8ef97184be2b6334 [file] [log] [blame]
<script>
var failed = false;
function runTest() {
window.onfocus = windowFocused;
window.onblur = windowBlurred;
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setMainFrameIsFirstResponder(true);
testRunner.setWindowFocus(false);
testRunner.setWindowFocus(true);
testRunner.setWindowFocus(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 testRunners 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>