tor-browser

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

test_http3_prio_disabled.js (3310B)


      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 // this test file can be run directly as a part of parent/main process
      6 // or indirectly from the wrapper test file as a part of child/content process
      7 
      8 // need to get access to helper functions/structures
      9 // load ensures
     10 // * testing environment is available (ie Assert.ok())
     11 /*global inChildProcess, test_flag_priority */
     12 load("../unit/test_http3_prio_helpers.js");
     13 
     14 // direct call to this test file should cleanup after itself
     15 // otherwise the wrapper will handle
     16 if (!inChildProcess()) {
     17  registerCleanupFunction(async () => {
     18    Services.prefs.clearUserPref("network.http.http3.priority");
     19    Services.prefs.clearUserPref("network.http.priority_header.enabled");
     20    http3_clear_prefs();
     21  });
     22 }
     23 
     24 // setup once, before tests
     25 add_task(async function setup() {
     26  // wrapper handles when testing as content process for pref change
     27  if (!inChildProcess()) {
     28    await http3_setup_tests("h3");
     29  }
     30 });
     31 
     32 // tests various flags when priority has been disabled on variable incremental
     33 // this function should only be called the preferences priority disabled
     34 async function test_http3_prio_disabled(incremental) {
     35  await test_flag_priority("disabled (none)", null, null, null, null); // default-test
     36  await test_flag_priority(
     37    "disabled (urgent_start)",
     38    Ci.nsIClassOfService.UrgentStart,
     39    null,
     40    incremental,
     41    null
     42  );
     43  await test_flag_priority(
     44    "disabled (leader)",
     45    Ci.nsIClassOfService.Leader,
     46    null,
     47    incremental,
     48    null
     49  );
     50  await test_flag_priority(
     51    "disabled (unblocked)",
     52    Ci.nsIClassOfService.Unblocked,
     53    null,
     54    incremental,
     55    null
     56  );
     57  await test_flag_priority(
     58    "disabled (follower)",
     59    Ci.nsIClassOfService.Follower,
     60    null,
     61    incremental,
     62    null
     63  );
     64  await test_flag_priority(
     65    "disabled (speculative)",
     66    Ci.nsIClassOfService.Speculative,
     67    null,
     68    incremental,
     69    null
     70  );
     71  await test_flag_priority(
     72    "disabled (background)",
     73    Ci.nsIClassOfService.Background,
     74    null,
     75    incremental,
     76    null
     77  );
     78  await test_flag_priority(
     79    "disabled (tail)",
     80    Ci.nsIClassOfService.Tail,
     81    null,
     82    incremental,
     83    null
     84  );
     85 }
     86 
     87 // run tests after setup
     88 
     89 // test that various urgency flags and incremental=true don't propogate to header
     90 // when priority setting is disabled
     91 add_task(async function test_http3_prio_disabled_inc_true() {
     92  // wrapper handles when testing as content process for pref change
     93  if (!inChildProcess()) {
     94    Services.prefs.setBoolPref("network.http.http3.priority", false);
     95    Services.prefs.setBoolPref("network.http.priority_header.enabled", false);
     96  }
     97  await test_http3_prio_disabled(true);
     98 });
     99 
    100 // test that various urgency flags and incremental=false don't propogate to header
    101 // when priority setting is disabled
    102 add_task(async function test_http3_prio_disabled_inc_false() {
    103  // wrapper handles when testing as content process for pref change
    104  if (!inChildProcess()) {
    105    Services.prefs.setBoolPref("network.http.http3.priority", false);
    106    Services.prefs.setBoolPref("network.http.priority_header.enabled", false);
    107  }
    108  await test_http3_prio_disabled(false);
    109 });