diff options
Diffstat (limited to 'dom/serviceworkers/test/abrupt_completion_worker.js')
-rw-r--r-- | dom/serviceworkers/test/abrupt_completion_worker.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/abrupt_completion_worker.js b/dom/serviceworkers/test/abrupt_completion_worker.js new file mode 100644 index 0000000000..7afebc6d45 --- /dev/null +++ b/dom/serviceworkers/test/abrupt_completion_worker.js @@ -0,0 +1,18 @@ +function setMessageHandler(response) { + onmessage = e => { + e.source.postMessage(response); + }; +} + +setMessageHandler("handler-before-throw"); + +// importScripts will throw when the ServiceWorker is past the "intalling" state. +importScripts(`empty.js?${Date.now()}`); + +// When importScripts throws an uncaught exception, these calls should never be +// made and the message handler should remain responding "handler-before-throw". +setMessageHandler("handler-after-throw"); + +// There needs to be a fetch handler to avoid the no-fetch optimizaiton, +// which will skip starting up this worker. +onfetch = e => e.respondWith(new Response("handler-after-throw")); |