From bc28ef58a83706de626d3d69d53cb2d0fd189141 Mon Sep 17 00:00:00 2001 From: Daniel Soromou Date: Fri, 4 Oct 2019 00:34:56 -0700 Subject: [PATCH] Service Worker: Fetch event added asynchronously doesn't throw. Based on the spec (https://github.com/whatwg/dom/pull/653), addEventListener after the first evaluation of the Service worker script should not throw. Change-Id: I46af276a67e021cf277a98195bf5c04583ad0b0a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1838376 Reviewed-by: Matt Falkenhagen Commit-Queue: Daniel Soromou Cr-Commit-Position: refs/heads/master@{#702753} --- .../service-worker/fetch-event-add-async.https.html | 11 +++++++++++ .../resources/fetch-event-add-async-worker.js | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 service-workers/service-worker/fetch-event-add-async.https.html create mode 100644 service-workers/service-worker/resources/fetch-event-add-async-worker.js diff --git a/service-workers/service-worker/fetch-event-add-async.https.html b/service-workers/service-worker/fetch-event-add-async.https.html new file mode 100644 index 00000000000000..ac13e4f41675c2 --- /dev/null +++ b/service-workers/service-worker/fetch-event-add-async.https.html @@ -0,0 +1,11 @@ + +Service Worker: Fetch event added asynchronously doesn't throw + + + + diff --git a/service-workers/service-worker/resources/fetch-event-add-async-worker.js b/service-workers/service-worker/resources/fetch-event-add-async-worker.js new file mode 100644 index 00000000000000..a5a44a57c99cb3 --- /dev/null +++ b/service-workers/service-worker/resources/fetch-event-add-async-worker.js @@ -0,0 +1,6 @@ +importScripts('/resources/testharness.js'); + +promise_test(async () => { + await new Promise(handler => { step_timeout(handler, 0); }); + self.addEventListener('fetch', () => {}); +}, 'fetch event added asynchronously does not throw');