tor-browser

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

port-blocking.https.window.js (1454B)


      1 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js
      2 // META: script=resources/utils.js
      3 'use strict';
      4 
      5 // Tests that requests to bad ports are blocked.
      6 // https://fetch.spec.whatwg.org/#port-blocking
      7 
      8 // This is not a comprehensive test of blocked ports - it is just intended to
      9 // check that blocking is enabled.
     10 
     11 backgroundFetchTest((t, bgFetch) => {
     12  return bgFetch.fetch(uniqueId(), 'https://example.com');
     13 }, 'fetch to default https port should register ok');
     14 
     15 backgroundFetchTest((t, bgFetch) => {
     16  return bgFetch.fetch(uniqueId(), 'http://127.0.0.1');
     17 }, 'fetch to default http port should register ok');
     18 
     19 backgroundFetchTest((t, bgFetch) => {
     20  return bgFetch.fetch(uniqueId(), 'https://example.com:443');
     21 }, 'fetch to port 443 should register ok');
     22 
     23 backgroundFetchTest((t, bgFetch) => {
     24  return bgFetch.fetch(uniqueId(), 'https://example.com:80');
     25 }, 'fetch to port 80 should register ok, even over https');
     26 
     27 backgroundFetchTest((t, bgFetch) => {
     28  return bgFetch.fetch(uniqueId(), 'https://example.com:8080');
     29 }, 'fetch to non-default non-bad port (8080) should register ok');
     30 
     31 backgroundFetchTest(async (t, bgFetch) => {
     32  const promise = bgFetch.fetch(uniqueId(), 'https://example.com:587').then(fetch => {
     33    return fetch.match('https://example.com:587');
     34  }).then(record => record.responseReady);
     35 
     36  return promise_rejects_js(
     37      t, TypeError,
     38      promise);
     39 }, 'fetch to bad port (SMTP) should reject');