fune/testing/web-platform/tests/background-fetch/update-ui.https.window.js
Rayan Kanso c860ad3488 Bug 1505173 [wpt PR 13955] - [Background Fetch] Reject call to updateUI if event is inactive., a=testonly
Automatic update from web-platform-tests[Background Fetch] Reject call to updateUI if event is inactive.

Spec:
https://wicg.github.io/background-fetch/#background-fetch-update-ui-event-update-ui

Bug: 901909
Change-Id: Ia319cd03e41e65c5a6a1f5e61cde6f4ae7705a32
Reviewed-on: https://chromium-review.googlesource.com/c/1320330
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606118}

--

wpt-commits: 8762072fac59630a7dd6e024dc7ceab71e86ffcc
wpt-pr: 13955
2018-11-14 13:38:05 +00:00

43 lines
1.5 KiB
JavaScript

// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/utils.js
'use strict';
// Covers functionality provided by BackgroundFetchUpdateUIEvent.updateUI().
//
// https://wicg.github.io/background-fetch/#backgroundfetchupdateuievent
const swName = 'sw-update-ui.js';
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'update-once';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
assert_equals(registration.id, registrationId);
const message = await getMessageFromServiceWorker();
assert_equals(message.update, 'update success');
}, 'Background Fetch updateUI resolves', swName);
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'update-twice';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
assert_equals(registration.id, registrationId);
const message = await getMessageFromServiceWorker();
assert_equals(message.update, 'InvalidStateError');
}, 'Background Fetch updateUI called twice fails', swName);
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'update-inactive';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
assert_equals(registration.id, registrationId);
const message = await getMessageFromServiceWorker();
assert_equals(message.update, 'InvalidStateError');
}, 'Background Fetch updateUI fails when event is not active', swName);