summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_http3_prio_disabled.js
blob: b73ca98709662cf0c67bc3fe962ae4e2e7221979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// this test file can be run directly as a part of parent/main process
// or indirectly from the wrapper test file as a part of child/content process

// need to get access to helper functions/structures
// load ensures
// * testing environment is available (ie Assert.ok())
/*global inChildProcess, test_flag_priority */
load("../unit/test_http3_prio_helpers.js");

// direct call to this test file should cleanup after itself
// otherwise the wrapper will handle
if (!inChildProcess()) {
  registerCleanupFunction(async () => {
    Services.prefs.clearUserPref("network.http.http3.priority");
    http3_clear_prefs();
  });
}

// setup once, before tests
add_task(async function setup() {
  // wrapper handles when testing as content process for pref change
  if (!inChildProcess()) {
    await http3_setup_tests("h3-29");
  }
});

// tests various flags when priority has been disabled on variable incremental
// this function should only be called the preferences priority disabled
async function test_http3_prio_disabled(incremental) {
  await test_flag_priority("disabled (none)", null, null, null, null); // default-test
  await test_flag_priority(
    "disabled (urgent_start)",
    Ci.nsIClassOfService.UrgentStart,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (leader)",
    Ci.nsIClassOfService.Leader,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (unblocked)",
    Ci.nsIClassOfService.Unblocked,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (follower)",
    Ci.nsIClassOfService.Follower,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (speculative)",
    Ci.nsIClassOfService.Speculative,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (background)",
    Ci.nsIClassOfService.Background,
    null,
    incremental,
    null
  );
  await test_flag_priority(
    "disabled (background)",
    Ci.nsIClassOfService.Tail,
    null,
    incremental,
    null
  );
}

// run tests after setup

// test that various urgency flags and incremental=true don't propogate to header
// when priority setting is disabled
add_task(async function test_http3_prio_disabled_inc_true() {
  // wrapper handles when testing as content process for pref change
  if (!inChildProcess()) {
    Services.prefs.setBoolPref("network.http.http3.priority", false);
  }
  await test_http3_prio_disabled(true);
});

// test that various urgency flags and incremental=false don't propogate to header
// when priority setting is disabled
add_task(async function test_http3_prio_disabled_inc_false() {
  // wrapper handles when testing as content process for pref change
  if (!inChildProcess()) {
    Services.prefs.setBoolPref("network.http.http3.priority", false);
  }
  await test_http3_prio_disabled(false);
});