<body>
<p>Test Timeouts (setTimeout, setInterval, clearTimeout, clearInterval).</p>
<div id=result></div>
<script>
var logIsFrozen = false;
function log(message)
{
    if (!logIsFrozen)
        document.getElementById("result").innerHTML += message + "<br>";
}

if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

var worker = new Worker('resources/worker-timeout.js');

worker.onmessage = function(evt) {
    log(evt.data);
    if (evt.data == "DONE") {
        // This flag is needed because in Chromium port, the notifyDone() does not immediately snapshots
        // the result and the still-firing timer in the worker may cause more messages to be logged before
        // actual termination of the test. However one objective of the test is to keep active interval
        // while the worker gets destroyed, so we freeze log rather then stop the interval from firing.
        // See https://bugs.webkit.org/show_bug.cgi?id=31452 for more info.
        logIsFrozen = true;
        if (window.layoutTestController)
            layoutTestController.notifyDone();
    } 
}
</script>
</body>
</html>
