summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/workers/worker-structure-message.html
blob: 10749affbe128bc6b3081b0a5e960b2d06fec884 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>
<body>
<p>Test that pages and workers can send Structure Message to one another.</p>
<p>On success, you will see a series of "PASS" messages, followed by "DONE".</p>
<div id=result></div>
<script>
function log(message)
{
    document.getElementById("result").innerHTML += message + "<br>";
}

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

var worker = new Worker("resources/worker-structure-message.js");
worker.onmessage = function(evt) {
    log(evt.data);
    if (evt.data.indexOf("FAIL") == 0) {
        done();
    }
    worker.onmessage = function(evt) {
        if (evt.data.operation == 'find-edges' &&
            ArrayBuffer.prototype.isPrototypeOf(evt.data.input) &&
            evt.data.input.byteLength == 20 &&
            evt.data.threshold == 0.6) {
                log("PASS: Receive correct structure message from Worker.");
        }
        else
            log("FAIL: Receive error structure message from Worker.");
        done();
    }
}

var buf = new ArrayBuffer(20);
worker.postMessage({
    operation: 'find-edges',
    input: buf,
    threshold: 0.6
});

function done()
{
    log("DONE");
    if (window.testRunner)
        testRunner.notifyDone();
}

</script>
</body>
</html>