https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 933c42829a0b57ae83016a14eaafb152d37d343b authored by Yoav Weiss on 21 December 2018, 21:00:08 UTC
Fix resource-timing.html document.domain test
Tip revision: 933c428
update-ui.https.window.js
// 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);
back to top