From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- netwerk/test/unit/test_http3_prio_enabled.js | 108 +++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 netwerk/test/unit/test_http3_prio_enabled.js (limited to 'netwerk/test/unit/test_http3_prio_enabled.js') diff --git a/netwerk/test/unit/test_http3_prio_enabled.js b/netwerk/test/unit/test_http3_prio_enabled.js new file mode 100644 index 0000000000..6dd30c590a --- /dev/null +++ b/netwerk/test/unit/test_http3_prio_enabled.js @@ -0,0 +1,108 @@ +/* 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 enabled on variable incremental +// this function should only be called the preferences priority disabled +async function test_http3_prio_enabled(incremental) { + await test_flag_priority("enabled (none)", null, "u=4", null, false); // default-test + await test_flag_priority( + "enabled (urgent_start)", + Ci.nsIClassOfService.UrgentStart, + "u=1", + incremental, + incremental + ); + await test_flag_priority( + "enabled (leader)", + Ci.nsIClassOfService.Leader, + "u=2", + incremental, + incremental + ); + + // if priority-urgency and incremental are both default values + // then we shouldn't expect to see the priority header at all + // hence when: + // incremental=true -> we expect incremental + // incremental=false -> we expect null + await test_flag_priority( + "enabled (unblocked)", + Ci.nsIClassOfService.Unblocked, + null, + incremental, + incremental ? incremental : null + ); + + await test_flag_priority( + "enabled (follower)", + Ci.nsIClassOfService.Follower, + "u=4", + incremental, + incremental + ); + await test_flag_priority( + "enabled (speculative)", + Ci.nsIClassOfService.Speculative, + "u=6", + incremental, + incremental + ); + await test_flag_priority( + "enabled (background)", + Ci.nsIClassOfService.Background, + "u=6", + incremental, + incremental + ); + await test_flag_priority( + "enabled (background)", + Ci.nsIClassOfService.Tail, + "u=6", + incremental, + incremental + ); +} + +// with priority enabled: test urgency flags with both incremental enabled and disabled +add_task(async function test_http3_prio_enabled_incremental_true() { + // wrapper handles when testing as content process for pref change + if (!inChildProcess()) { + Services.prefs.setBoolPref("network.http.http3.priority", true); + } + await test_http3_prio_enabled(true); +}); + +add_task(async function test_http3_prio_enabled_incremental_false() { + // wrapper handles when testing as content process for pref change + if (!inChildProcess()) { + Services.prefs.setBoolPref("network.http.http3.priority", true); + } + await test_http3_prio_enabled(false); +}); -- cgit v1.2.3