tor-browser

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

interface-requirements-worker.sub.js (2492B)


      1 'use strict';
      2 
      3 // This file checks additional interface requirements, on top of the basic IDL
      4 // that is validated in service-workers/idlharness.any.js
      5 
      6 importScripts('/resources/testharness.js');
      7 
      8 test(function() {
      9    var req = new Request('http://{{host}}/',
     10                          {method: 'POST',
     11                           headers: [['Content-Type', 'Text/Html']]});
     12    assert_equals(
     13      new ExtendableEvent('ExtendableEvent').type,
     14      'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent');
     15    assert_throws_js(TypeError, function() {
     16        new FetchEvent('FetchEvent');
     17    }, 'FetchEvent constructor with one argument throws');
     18    assert_throws_js(TypeError, function() {
     19        new FetchEvent('FetchEvent', {});
     20    }, 'FetchEvent constructor with empty init dict throws');
     21    assert_throws_js(TypeError, function() {
     22        new FetchEvent('FetchEvent', {request: null});
     23    }, 'FetchEvent constructor with null request member throws');
     24    assert_equals(
     25      new FetchEvent('FetchEvent', {request: req}).type,
     26      'FetchEvent', 'Type of FetchEvent should be FetchEvent');
     27    assert_equals(
     28      new FetchEvent('FetchEvent', {request: req}).cancelable,
     29      false, 'Default FetchEvent.cancelable should be false');
     30    assert_equals(
     31      new FetchEvent('FetchEvent', {request: req}).bubbles,
     32      false, 'Default FetchEvent.bubbles should be false');
     33    assert_equals(
     34      new FetchEvent('FetchEvent', {request: req}).clientId,
     35      '', 'Default FetchEvent.clientId should be the empty string');
     36    assert_equals(
     37      new FetchEvent('FetchEvent', {request: req, cancelable: false}).cancelable,
     38      false, 'FetchEvent.cancelable should be false');
     39    assert_equals(
     40      new FetchEvent('FetchEvent', {request: req, clientId : 'test-client-id'}).clientId, 'test-client-id',
     41      'FetchEvent.clientId with option {clientId : "test-client-id"} should be "test-client-id"');
     42    assert_equals(
     43      new FetchEvent('FetchEvent', {request : req}).request.url,
     44      'http://{{host}}/',
     45      'FetchEvent.request.url should return the value it was initialized to');
     46    assert_equals(
     47      new FetchEvent('FetchEvent', {request : req}).isReload,
     48      undefined,
     49      'FetchEvent.isReload should not exist');
     50 
     51  }, 'Event constructors');
     52 
     53 test(() => {
     54    assert_false('XMLHttpRequest' in self);
     55  }, 'xhr is not exposed');
     56 
     57 test(() => {
     58    assert_false('createObjectURL' in self.URL);
     59  }, 'URL.createObjectURL is not exposed')