SharedWorker-exception-propagation.html (1333B)
1 <!DOCTYPE html> 2 <title>Uncaught error in shared worker should not propagate to window</title> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/workers.html#runtime-script-errors-2"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="support/SharedWorker-create-common.js"></script> 7 <script> 8 // Suppress the default handling of the error event so that a failure 9 // manifests as a failed test and not a harness error. 10 setup({ allow_uncaught_exception: true }); 11 12 async_test(function(t) { 13 addEventListener("error", t.unreached_func("error event fired")); 14 var worker = createWorker(); 15 worker.postMessage("throw"); 16 worker.postMessage("ping"); 17 var pongs = 0; 18 worker.onmessage = function(evt) { 19 // Wait for response from ping - that's how we know we have thrown the exception. 20 if (evt.data == "PASS: Received ping message") { 21 pongs++; 22 if (pongs == 1) { 23 // Send another "ping" message and wait for the response before 24 // ending the test, so that any error propagation that is now 25 // in flight will have finished. 26 worker.postMessage("ping"); 27 } else { 28 t.done(); 29 } 30 } 31 }; 32 }); 33 </script>