commit 10601476c58592359e676e95c5776e927ac10a8c
parent def1192f9f55316dc40eca8cfa02a142c9cb5247
Author: Randell Jesup <rjesup@mozilla.com>
Date: Wed, 17 Dec 2025 14:25:53 +0000
Bug 2006103: fix Dictionary test to allow for intermittent failure when we corrupt the hash r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D276738
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/netwerk/test/unit/test_dictionary_replacement.js b/netwerk/test/unit/test_dictionary_replacement.js
@@ -58,12 +58,18 @@ function makeChan(url, bypassCache = false) {
return chan;
}
-function channelOpenPromise(chan) {
+function channelOpenPromise(chan, intermittentFail = false) {
return new Promise(resolve => {
function finish(req, buffer) {
resolve([req, buffer]);
}
- chan.asyncOpen(new ChannelListener(finish, null, CL_ALLOW_UNKNOWN_CL));
+ if (intermittentFail) {
+ chan.asyncOpen(
+ new SimpleChannelListener(finish, null, CL_ALLOW_UNKNOWN_CL)
+ );
+ } else {
+ chan.asyncOpen(new ChannelListener(finish, null, CL_ALLOW_UNKNOWN_CL));
+ }
});
}
@@ -621,7 +627,7 @@ add_task(async function test_dictionary_hash_mismatch() {
// which will fail due to hash mismatch. The channel should be cancelled.
chan = makeChan(matchingUrl);
try {
- await channelOpenPromise(chan);
+ await channelOpenPromise(chan, true); // intermittent failure
} catch (e) {
dump(`**** Request failed with: ${e}\n`);
}