tor-browser

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

no-feature-policy.sub.https.html (3169B)


      1 <html>
      2 <body>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/get-host-info.sub.js"></script>
      6 <script>
      7 
      8 // If the response for the HTML file contains "Accept-CH" in the response
      9 // headers, then the browser should attach the specified client hints in the
     10 // HTTP request headers depending on whether the resource is being fetched from
     11 // the same origin or a different origin. Test this functionality by fetching
     12 // same-origin and cross-origin resources from this page. The response headers
     13 // for this page include "Accept-CH: device-memory, dpr, viewport-width, rtt, downlink, ect".
     14 //
     15 // resources/echo-client-hints-received.py sets the response headers depending on the set
     16 // of client hints it receives in the request headers.
     17 
     18 promise_test(t => {
     19  return fetch(get_host_info()["HTTPS_ORIGIN"] + "/client-hints/resources/echo-client-hints-received.py").then(r => {
     20    assert_equals(r.status, 200)
     21    // Verify that the browser includes client hints in the headers for a
     22    // same-origin fetch with the default feature policy in place.
     23    assert_true(r.headers.has("device-memory-received"), "device-memory-received");
     24    assert_true(r.headers.has("device-memory-deprecated-received"), "device-memory-deprecated-received");
     25    assert_true(r.headers.has("dpr-received"), "dpr-received");
     26    assert_true(r.headers.has("dpr-deprecated-received"), "dpr-deprecated-received");
     27    assert_true(r.headers.has("viewport-width-received"), "viewport-width-received");
     28    assert_true(r.headers.has("viewport-width-deprecated-received"), "viewport-width-deprecated-received");
     29 
     30    assert_true(r.headers.has("rtt-received"), "rtt-received");
     31    var rtt = parseInt(r.headers.get("rtt-received"));
     32    assert_greater_than_equal(rtt, 0);
     33    assert_less_than_equal(rtt, 3000);
     34    assert_equals(rtt % 50, 0, 'rtt must be a multiple of 50 msec');
     35 
     36    assert_true(r.headers.has("downlink-received"), "downlink-received");
     37    var downlinkKbps  = r.headers.get("downlink-received") * 1000;
     38    assert_greater_than_equal(downlinkKbps, 0);
     39    assert_less_than_equal(downlinkKbps, 10000);
     40 
     41    assert_in_array(r.headers.get("ect-received"), ["slow-2g", "2g",
     42          "3g", "4g"], 'ect-received is unexpected');
     43  });
     44 }, "Accept-CH header test");
     45 
     46 promise_test(t => {
     47  return fetch(get_host_info()["HTTPS_REMOTE_ORIGIN"] + "/client-hints/resources/echo-client-hints-received.py").then(r => {
     48    assert_equals(r.status, 200)
     49    // Verify that the browser includes no client hints in the headers for a
     50    // cross-origin fetch with the default feature policy in place.
     51    assert_false(r.headers.has("device-memory-received"), "device-memory-received");
     52    assert_false(r.headers.has("dpr-received"), "dpr-received");
     53    assert_false(r.headers.has("viewport-width-received"), "viewport-width-received");
     54    assert_false(r.headers.has("rtt-received"), "rtt-received");
     55    assert_false(r.headers.has("downlink-received"), "downlink-received");
     56    assert_false(r.headers.has("ect-received"), "ect-received");
     57  });
     58 }, "Cross-Origin Accept-CH header test");
     59 
     60 
     61 
     62 </script>
     63 
     64 </body>
     65 </html>