summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/Worker_basic.htm
blob: d2b57b4918b06c1d8fa9e31c83bc2f36a5d34496 (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
<!DOCTYPE html>
<title> Web Workers Basic Tests </title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
function create_worker() {
  return new Worker('./support/WorkerBasic.js');
}

test(function() {
  var worker = create_worker();
  assert_class_string(worker, "Worker");
}, "Worker constructor");

async_test(function(t) {
  var worker = create_worker();
  worker.onmessage = t.step_func_done(function(e) {
    assert_equals(e.data, "Pass");
  });
  worker.postMessage("start");
}, "MessageEvent.data");

async_test(function(t) {
  var worker = create_worker();
  worker.addEventListener("message", t.step_func_done(function(e) {
    assert_equals(e.type, "message");
  }), true);
  worker.postMessage("start");
}, "MessageEvent.type");
</script>