tor-browser

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

browser_103_http_v1_1_preload.js (2094B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 Services.prefs.setBoolPref("network.early-hints.enabled", true);
      8 Services.prefs.setBoolPref("network.early-hints.over-http-v1-1.enabled", true);
      9 
     10 // Disable mixed-content upgrading as this test is expecting HTTP image loads
     11 Services.prefs.setBoolPref(
     12  "security.mixed_content.upgrade_display_content",
     13  false
     14 );
     15 
     16 const { request_count_checking, test_preload_url, test_hint_preload } =
     17  ChromeUtils.importESModule(
     18    "resource://testing-common/early_hint_preload_test_helper.sys.mjs"
     19  );
     20 
     21 // Test that with both early hints and early hints over http v1-1 prefs are disabled,
     22 // no early hint requests are made
     23 add_task(async function test_103_both_preload_disabled() {
     24  Services.prefs.setBoolPref("network.early-hints.enabled", false);
     25  Services.prefs.setBoolPref(
     26    "network.early-hints.over-http-v1-1.enabled",
     27    false
     28  );
     29  await test_hint_preload(
     30    "test_103_preload_disabled",
     31    "https://example.com",
     32    "https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs",
     33    { hinted: 0, normal: 1 }
     34  );
     35  Services.prefs.setBoolPref("network.early-hints.enabled", true);
     36  Services.prefs.setBoolPref(
     37    "network.early-hints.over-http-v1-1.enabled",
     38    true
     39  );
     40 });
     41 
     42 // Test that with only early hints over http v1-1 config option is disabled, no early hint requests are made
     43 add_task(async function test_103_http_v1_1_preload_disabled() {
     44  Services.prefs.setBoolPref("network.early-hints.enabled", true);
     45  Services.prefs.setBoolPref("network.early-hints.enabled", false);
     46  await test_hint_preload(
     47    "test_103_preload_disabled",
     48    "https://example.com",
     49    "https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs",
     50    { hinted: 0, normal: 1 }
     51  );
     52  Services.prefs.setBoolPref("network.early-hints.enabled", true);
     53  Services.prefs.setBoolPref(
     54    "network.early-hints.over-http-v1-1.enabled",
     55    true
     56  );
     57 });