diff options
author | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2018-11-07 21:06:07 -0500 |
---|---|---|
committer | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2018-11-07 22:27:51 -0500 |
commit | 44434263087ebb0d58766c10c9c9ac69c9b32b51 (patch) | |
tree | d9225cb0186fef92c73ed1ad8c58c99db5f23876 /tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js | |
parent | 2ed23ce4c9ce43da7a8cbc8dd94b46574ca9fec5 (diff) | |
download | servo-44434263087ebb0d58766c10c9c9ac69c9b32b51.tar.gz servo-44434263087ebb0d58766c10c9c9ac69c9b32b51.zip |
Update web-platform-tests to revision cd44958a002b1ad494168e0290554644de84526e
Diffstat (limited to 'tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js')
-rw-r--r-- | tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js b/tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js index 5dec087cd15..3848dc4402b 100644 --- a/tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js +++ b/tests/wpt/web-platform-tests/background-fetch/service_workers/sw-update-ui.js @@ -1,3 +1,4 @@ +importScripts('/resources/testharness.js'); importScripts('sw-helpers.js'); async function updateUI(event) { @@ -13,10 +14,20 @@ async function updateUI(event) { return Promise.all(updateParams.map(param => event.updateUI(param))) .then(() => 'update success') - .catch(e => e.message); + .catch(e => e.name); } self.addEventListener('backgroundfetchsuccess', event => { + if (event.registration.id === 'update-inactive') { + // Post an async task before calling updateUI from the inactive event. + // Any async behaviour outside `waitUntil` should mark the event as + // inactive, and subsequent calls to `updateUI` should fail. + new Promise(r => step_timeout(r, 0)) + .then(() => event.updateUI({ title: 'New title' })) + .catch(e => sendMessageToDocument({ update: e.name })); + return; + } + event.waitUntil(updateUI(event) - .then(update => sendMessageToDocument({ type: event.type, update }))) + .then(update => sendMessageToDocument({ update }))); }); |