From 40249078c8424c1ac4c68573a26708f81bb8ae20 Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Fri, 26 Feb 2021 15:34:57 +0000 Subject: [PATCH] Bug 1694521 - Part 4: In test_trr_flags, check that the channel actually used TRR if possible. r=valentin,necko-reviewers Differential Revision: https://phabricator.services.mozilla.com/D106423 --- .../protocol/http/nsIHttpChannelInternal.idl | 2 +- netwerk/test/unit/test_trr.js | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/netwerk/protocol/http/nsIHttpChannelInternal.idl b/netwerk/protocol/http/nsIHttpChannelInternal.idl index ea079ee221f6..0d6bce641475 100644 --- a/netwerk/protocol/http/nsIHttpChannelInternal.idl +++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl @@ -264,7 +264,7 @@ interface nsIHttpChannelInternal : nsISupports * Is false for resources loaded from the cache or resources that have an * IP literal host. */ - [noscript, must_use] readonly attribute boolean isResolvedByTRR; + [must_use] readonly attribute boolean isResolvedByTRR; /** * An opaque flags for non-standard behavior of the TLS system. diff --git a/netwerk/test/unit/test_trr.js b/netwerk/test/unit/test_trr.js index 9564b9bf9b7a..fea6145342d0 100644 --- a/netwerk/test/unit/test_trr.js +++ b/netwerk/test/unit/test_trr.js @@ -110,7 +110,7 @@ add_task(async function test_trr_flags() { const URL = `http://example.com:${httpserv.identity.primaryPort}/`; for (let mode of [0, 1, 2, 3, 4, 5]) { - setModeAndURI(mode, "404"); + setModeAndURI(mode, "doh?responseIP=127.0.0.1"); for (let flag of [ Ci.nsIRequest.TRR_DEFAULT_MODE, Ci.nsIRequest.TRR_DISABLED_MODE, @@ -119,17 +119,22 @@ add_task(async function test_trr_flags() { ]) { dns.clearCache(true); let chan = makeChan(URL, flag); - let channelFlags; - if ( - ([0, 2, 3].includes(mode) && flag == Ci.nsIRequest.TRR_ONLY_MODE) || - (mode == 3 && flag == Ci.nsIRequest.TRR_DEFAULT_MODE) - ) { - channelFlags = CL_EXPECT_FAILURE; - } + let expectTRR = + ([2, 3].includes(mode) && flag != Ci.nsIRequest.TRR_DISABLED_MODE) || + (mode == 0 && + [Ci.nsIRequest.TRR_FIRST_MODE, Ci.nsIRequest.TRR_ONLY_MODE].includes( + flag + )); + await new Promise(resolve => - chan.asyncOpen(new ChannelListener(resolve, null, channelFlags)) + chan.asyncOpen(new ChannelListener(resolve)) ); + equal(chan.getTRRMode(), flag); + equal( + expectTRR, + chan.QueryInterface(Ci.nsIHttpChannelInternal).isResolvedByTRR + ); } }