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