summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/workers/worker-timeout.html
blob: cd7e5d148c5a13bd78193824437cbfac0dbcfe6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<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.testRunner) {
    testRunner.dumpAsText();
    testRunner.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.testRunner)
            testRunner.notifyDone();
    } 
}
</script>
</body>
</html>