<html>
<head>
<script>
    function runTests()
    {
        window.onfocus = onFocusFunc;
        window.onblur = onBlurFunc;
        if (window.layoutTestController) {
            layoutTestController.dumpAsText();
            layoutTestController.setCanOpenWindows();
            layoutTestController.waitUntilDone();

            // DumpRenderTreeWindow does not respond to focus events.  Forcing onblur event so
            // that the results matches what you'll see in the browser.
            layoutTestController.setWindowIsKey(false);
        }
        showModalDialog("resources/modal-dialog.html");
    }

    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 onBlurFunc()
    {
        log("onblur fired.  Should see this exactly once.");
    }

    function onFocusFunc()
    {
        log("ERROR: onfocus fired.");
    }
</script>
</head>

<body onload="runTests()">
    <p>Pop up a modal dialog.  Verifies that focus events are not fired while inside the message loop.</p><br/>
    <p>You need to disable pop-up blocker for this test to run successfully in the browser.</p>
    <ul id="console"></ul>
</body>
</html>
