tor-browser

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

accept-ch-change.https.html (3262B)


      1 <!DOCTYPE html>
      2 <html>
      3 <title>Accept-CH test</title>
      4 <body>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="resources/open-and-add-load-event.js"></script>
      8 
      9 <!--
     10 Apart from this webpage, the test opens two more html web page. One test is run
     11 in this web page, and two in the other web pages.
     12 -->
     13 
     14 <script>
     15 
     16 // This test fetches resources/accept_ch.html. The response headers to
     17 // that webpage contains only the Accept-CH header. These preferences should be
     18 // stored so that the next request to the same origin is sent with the
     19 // requested client hint headers.
     20 
     21 // Next, to verify that the origin preferences were persisted by the user
     22 // agent, this test fetches resources/expect_client_hints_headers.html in a new
     23 // window. Fetching of resources/expect_client_hints_headers.html verifies that
     24 // the user agent does send the client hints in the request headers.
     25 
     26 // After this, the same is done but with a differet Accept-CH header, to test
     27 // that the preferences change after receiving a different header.
     28 
     29 promise_test(async () => {
     30  r = await fetch("resources/echo-client-hints-received.py");
     31 
     32  assert_equals(r.status, 200);
     33  // Verify that the browser did not include client hints in the request
     34  // headers when fetching echo_client_hints_received.py.
     35  assert_false(r.headers.has("device-memory-received"), "device-memory-received");
     36  assert_false(r.headers.has("device-memory-deprecated-received"), "device-memory-deprecated-received");
     37  assert_false(r.headers.has("viewport-width-received"), "viewport-width-received");
     38  assert_false(r.headers.has("viewport-width-deprecated-received"), "viewport-width-deprecated-received");
     39 
     40  // Fetching this webpage should cause user-agent to persist client hint
     41  // preferences for the origin.
     42  await open_and_add_load_event("resources/accept-ch.html");
     43 
     44  // Open a new window. Verify that the user agent does attach the client hints.
     45  await open_and_expect_headers("resources/expect-client-hints-headers.html");
     46 
     47  // Use new window to overwrite client hint preferences, then verify new
     48  // settings have been saved
     49  await open_and_add_load_event("resources/accept-ch-different.html");
     50 
     51  // Use new window to overwrite client hint preferences, then verify new
     52  // settings have been saved
     53  await open_and_expect_headers("resources/expect-different-client-hints-headers.html");
     54 
     55  // Use new window to overwrite client hint preferences, then verify new
     56  // settings have been saved
     57  await open_and_add_load_event("resources/accept-ch-empty.html");
     58 
     59  // Use new window to overwrite client hint preferences, then verify new
     60  // settings have been saved
     61  await open_and_expect_headers("resources/expect-no-client-hints-headers.html");
     62 
     63  // Check that multiple headers will fill the cache.
     64  await open_and_add_load_event("resources/accept-ch-split.html");
     65  await open_and_expect_headers("resources/expect-client-hints-headers.html");
     66 
     67  // Check that a mix of empty and full headers drops the cache.
     68  await open_and_add_load_event("resources/accept-ch-mixed.html");
     69  await open_and_expect_headers("resources/expect-no-client-hints-headers.html");
     70 
     71 }, "Accept-CH changes based on header");
     72 
     73 </script>
     74 </body>
     75 </html>