<script>
var failed = false;

function runTest() {
    window.onfocus = windowFocused;
    window.onblur = windowBlurred;
    
    if (window.testRunner) {
        window.testRunner.dumpAsText();
        window.testRunner.setMainFrameIsFirstResponder(true);
        
        window.testRunner.setWindowIsKey(false);
        window.testRunner.setWindowIsKey(true);
        window.testRunner.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 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>
