tor-browser

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

idlharness.https.any.js (1966B)


      1 // META: global=window,worker
      2 // META: script=/resources/WebIDLParser.js
      3 // META: script=/resources/idlharness.js
      4 // META: script=cache-storage/resources/test-helpers.js
      5 // META: script=service-worker/resources/test-helpers.sub.js
      6 // META: timeout=long
      7 
      8 // https://w3c.github.io/ServiceWorker
      9 
     10 idl_test(
     11  ['service-workers'],
     12  ['dom', 'html'],
     13  async (idl_array, t) => {
     14    self.cacheInstance = await create_temporary_cache(t);
     15 
     16    idl_array.add_objects({
     17      CacheStorage: ['caches'],
     18      Cache: ['self.cacheInstance'],
     19      ServiceWorkerContainer: ['navigator.serviceWorker']
     20    });
     21 
     22    // TODO: Add ServiceWorker and ServiceWorkerRegistration instances for the
     23    // other worker scopes.
     24    if (self.GLOBAL.isWindow()) {
     25      idl_array.add_objects({
     26        ServiceWorkerRegistration: ['registrationInstance'],
     27        ServiceWorker: ['registrationInstance.installing']
     28      });
     29 
     30      const scope = 'service-worker/resources/scope/idlharness';
     31      const registration = await service_worker_unregister_and_register(
     32          t, 'service-worker/resources/empty-worker.js', scope);
     33      t.add_cleanup(() => registration.unregister());
     34 
     35      self.registrationInstance = registration;
     36    } else if (self.ServiceWorkerGlobalScope) {
     37      // self.ServiceWorkerGlobalScope should only be defined for the
     38      // ServiceWorker scope, which allows us to detect and test the interfaces
     39      // exposed only for ServiceWorker.
     40      idl_array.add_objects({
     41        Clients: ['clients'],
     42        ExtendableEvent: ['new ExtendableEvent("type")'],
     43        FetchEvent: ['new FetchEvent("type", { request: new Request("") })'],
     44        ServiceWorkerGlobalScope: ['self'],
     45        ServiceWorkerRegistration: ['registration'],
     46        ServiceWorker: ['serviceWorker'],
     47        // TODO: Test instances of Client and WindowClient, e.g.
     48        // Client: ['self.clientInstance'],
     49        // WindowClient: ['self.windowClientInstance']
     50      });
     51    }
     52  }
     53 );