OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 (function f() { |
| 3 postMessage(1); |
| 4 setTimeout(f, 0); |
| 5 })(); |
| 6 /* |
| 7 --> |
| 8 <!doctype html> |
| 9 <title>terminate()</title> |
| 10 <link rel=help href="http://www.whatwg.org/html/#dom-worker-terminate"> |
| 11 <script src="/resources/testharness.js"></script> |
| 12 <script src="/resources/testharnessreport.js"></script> |
| 13 <div id="log"></div> |
| 14 <script> |
| 15 var t = async_test(); |
| 16 t.step(function() { |
| 17 var worker = new Worker('#'); |
| 18 var i = 0; |
| 19 var expected; |
| 20 |
| 21 worker.onmessage = t.step_func(function() { |
| 22 i++; |
| 23 }); |
| 24 |
| 25 setTimeout(t.step_func(function() { |
| 26 expected = i; |
| 27 start_time = Date.now(); |
| 28 //Hang the main thread for a bit to give the worker the chance to post some
more messages |
| 29 while(Date.now() - start_time < 500) { |
| 30 //pass |
| 31 } |
| 32 worker.terminate(); |
| 33 |
| 34 setTimeout(t.step_func(function() { |
| 35 assert_equals(i, expected); |
| 36 t.done(); |
| 37 }), 100); |
| 38 |
| 39 }), 100); |
| 40 }); |
| 41 </script> |
| 42 <!-- |
| 43 */ |
| 44 //--> |
OLD | NEW |