tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

update-ui.https.window.js (1584B)


      1 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js
      2 // META: script=resources/utils.js
      3 'use strict';
      4 
      5 // Covers functionality provided by BackgroundFetchUpdateUIEvent.updateUI().
      6 //
      7 // https://wicg.github.io/background-fetch/#backgroundfetchupdateuievent
      8 
      9 const swName = 'sw-update-ui.js';
     10 
     11 backgroundFetchTest(async (test, backgroundFetch) => {
     12  const registrationId = 'update-once';
     13  const registration =
     14      await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
     15  assert_equals(registration.id, registrationId);
     16 
     17  const message = await getMessageFromServiceWorker();
     18  assert_equals(message.update, 'update success');
     19 
     20 }, 'Background Fetch updateUI resolves', swName);
     21 
     22 
     23 backgroundFetchTest(async (test, backgroundFetch) => {
     24  const registrationId = 'update-twice';
     25  const registration =
     26      await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
     27  assert_equals(registration.id, registrationId);
     28 
     29  const message = await getMessageFromServiceWorker();
     30  assert_equals(message.update, 'InvalidStateError');
     31 
     32 }, 'Background Fetch updateUI called twice fails', swName);
     33 
     34 backgroundFetchTest(async (test, backgroundFetch) => {
     35  const registrationId = 'update-inactive';
     36  const registration =
     37      await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
     38  assert_equals(registration.id, registrationId);
     39 
     40  const message = await getMessageFromServiceWorker();
     41  assert_equals(message.update, 'InvalidStateError');
     42 
     43 }, 'Background Fetch updateUI fails when event is not active', swName);