From b0a610bce56921bfe57c225f2759ff34da8ec226 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru Michis Date: Mon, 8 Jun 2020 12:51:42 +0300 Subject: [PATCH] Backed out 3 changesets (bug 1640091) for causing xpcshell failures in nsCOMPtr.h CLOSED TREE Backed out changeset 03c4c517ee37 (bug 1640091) Backed out changeset a1d86c177d79 (bug 1640091) Backed out changeset f481d4ec255a (bug 1640091) --- netwerk/base/ProxyAutoConfig.cpp | 15 +-- netwerk/ipc/ProxyConfigLookup.cpp | 10 +- netwerk/ipc/ProxyConfigLookup.h | 5 +- netwerk/protocol/http/TRRServiceChannel.cpp | 2 +- netwerk/test/unit/head_trr.js | 1 - netwerk/test/unit/test_trr_proxy.js | 124 -------------------- netwerk/test/unit/xpcshell.ini | 1 - 7 files changed, 10 insertions(+), 148 deletions(-) delete mode 100644 netwerk/test/unit/test_trr_proxy.js diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 480152fbd6f5..37c6035aa75d 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -441,18 +441,11 @@ bool ProxyAutoConfig::ResolveAddress(const nsCString& aHostName, RefPtr helper = new PACResolver(mMainThreadEventTarget); OriginAttributes attrs; - // When the PAC script attempts to resolve a domain, we must make sure we - // don't use TRR, otherwise the TRR channel might also attempt to resolve - // a name and we'll have a deadlock. - uint32_t flags = - nsIDNSService::RESOLVE_PRIORITY_MEDIUM | - nsIDNSService::GetFlagsFromTRRMode(nsIRequest::TRR_DISABLED_MODE); - - if (NS_FAILED(dns->AsyncResolveNative(aHostName, flags, helper, - GetCurrentThreadEventTarget(), attrs, - getter_AddRefs(helper->mRequest)))) { + if (NS_FAILED(dns->AsyncResolveNative( + aHostName, nsIDNSService::RESOLVE_PRIORITY_MEDIUM, helper, + GetCurrentThreadEventTarget(), attrs, + getter_AddRefs(helper->mRequest)))) return false; - } if (aTimeout && helper->mRequest) { if (!mTimer) mTimer = NS_NewTimer(); diff --git a/netwerk/ipc/ProxyConfigLookup.cpp b/netwerk/ipc/ProxyConfigLookup.cpp index 2dc2f8704ace..5f96db5b7b7b 100644 --- a/netwerk/ipc/ProxyConfigLookup.cpp +++ b/netwerk/ipc/ProxyConfigLookup.cpp @@ -20,12 +20,12 @@ namespace net { // static nsresult ProxyConfigLookup::Create( std::function&& aCallback, nsIURI* aURI, - uint32_t aProxyResolveFlags, nsICancelable** aLookupCancellable) { + uint32_t aProxyResolveFlags) { MOZ_ASSERT(NS_IsMainThread()); RefPtr lookUp = new ProxyConfigLookup(std::move(aCallback), aURI, aProxyResolveFlags); - return lookUp->DoProxyResolve(aLookupCancellable); + return lookUp->DoProxyResolve(); } ProxyConfigLookup::ProxyConfigLookup( @@ -37,7 +37,7 @@ ProxyConfigLookup::ProxyConfigLookup( ProxyConfigLookup::~ProxyConfigLookup() = default; -nsresult ProxyConfigLookup::DoProxyResolve(nsICancelable** aLookupCancellable) { +nsresult ProxyConfigLookup::DoProxyResolve() { if (!XRE_IsParentProcess()) { RefPtr self = this; bool result = ProxyConfigLookupChild::Create( @@ -77,10 +77,6 @@ nsresult ProxyConfigLookup::DoProxyResolve(nsICancelable** aLookupCancellable) { getter_AddRefs(proxyRequest)); } - if (aLookupCancellable) { - proxyRequest.forget(aLookupCancellable); - } - return rv; } diff --git a/netwerk/ipc/ProxyConfigLookup.h b/netwerk/ipc/ProxyConfigLookup.h index da935c9028a1..5b53a67df296 100644 --- a/netwerk/ipc/ProxyConfigLookup.h +++ b/netwerk/ipc/ProxyConfigLookup.h @@ -22,15 +22,14 @@ class ProxyConfigLookup final : public nsIProtocolProxyCallback { static nsresult Create( std::function&& aCallback, nsIURI* aURI, - uint32_t aProxyResolveFlags, - nsICancelable** aLookupCancellable = nullptr); + uint32_t aProxyResolveFlags); private: explicit ProxyConfigLookup( std::function&& aCallback, nsIURI* aURI, uint32_t aProxyResolveFlags); virtual ~ProxyConfigLookup(); - nsresult DoProxyResolve(nsICancelable** aLookupCancellable); + nsresult DoProxyResolve(); std::function mCallback; nsCOMPtr mURI; diff --git a/netwerk/protocol/http/TRRServiceChannel.cpp b/netwerk/protocol/http/TRRServiceChannel.cpp index 6d5106c4170d..7acc66a8afef 100644 --- a/netwerk/protocol/http/TRRServiceChannel.cpp +++ b/netwerk/protocol/http/TRRServiceChannel.cpp @@ -252,7 +252,7 @@ nsresult TRRServiceChannel::ResolveProxy() { [self](nsIProxyInfo* aProxyInfo, nsresult aStatus) { self->OnProxyAvailable(nullptr, nullptr, aProxyInfo, aStatus); }, - mURI, mProxyResolveFlags, getter_AddRefs(mProxyRequest)); + mURI, mProxyResolveFlags); if (NS_FAILED(rv)) { if (!mCurrentEventTarget->IsOnCurrentThread()) { diff --git a/netwerk/test/unit/head_trr.js b/netwerk/test/unit/head_trr.js index 88fad7a17f05..f3c2155093e4 100644 --- a/netwerk/test/unit/head_trr.js +++ b/netwerk/test/unit/head_trr.js @@ -68,7 +68,6 @@ function trr_clear_prefs() { Services.prefs.clearUserPref("network.trr.excluded-domains"); Services.prefs.clearUserPref("network.trr.builtin-excluded-domains"); Services.prefs.clearUserPref("network.trr.clear-cache-on-pref-change"); - Services.prefs.clearUserPref("network.trr.fetch_off_main_thread"); Services.prefs.clearUserPref("captivedetect.canonicalURL"); Services.prefs.clearUserPref("network.http.spdy.enabled"); diff --git a/netwerk/test/unit/test_trr_proxy.js b/netwerk/test/unit/test_trr_proxy.js deleted file mode 100644 index 54d0ac911fa2..000000000000 --- a/netwerk/test/unit/test_trr_proxy.js +++ /dev/null @@ -1,124 +0,0 @@ -/* globals dnsResolve */ - -const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js"); -const { MockRegistrar } = ChromeUtils.import( - "resource://testing-common/MockRegistrar.jsm" -); -const dns = Cc["@mozilla.org/network/dns-service;1"].getService( - Ci.nsIDNSService -); - -trr_test_setup(); -registerCleanupFunction(async () => { - trr_clear_prefs(); -}); - -function FindProxyForURL(url, host) { - alert(`PAC resolving: ${host}`); - alert(dnsResolve(host)); - return "DIRECT"; -} - -const CID = Components.ID("{5645d2c1-d6d8-4091-b117-fe7ee4027db7}"); -XPCOMUtils.defineLazyGetter(this, "systemSettings", function() { - return { - QueryInterface: ChromeUtils.generateQI(["nsISystemProxySettings"]), - - mainThreadOnly: true, - PACURI: `data:application/x-ns-proxy-autoconfig;charset=utf-8,${encodeURIComponent( - FindProxyForURL.toString() - )}`, - getProxyForURI(aURI) { - throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED); - }, - }; -}); - -const override = Cc["@mozilla.org/network/native-dns-override;1"].getService( - Ci.nsINativeDNSResolverOverride -); - -add_task(async function test_pac_dnsResolve() { - Services.console.reset(); - // Create a console listener. - let consolePromise = new Promise(resolve => { - let listener = { - observe(message) { - // Ignore unexpected messages. - if (!(message instanceof Ci.nsIConsoleMessage)) { - return; - } - - if (message.message.includes("PAC file installed from")) { - Services.console.unregisterListener(listener); - resolve(); - } - }, - }; - - Services.console.registerListener(listener); - }); - - MockRegistrar.register( - "@mozilla.org/system-proxy-settings;1", - systemSettings - ); - Services.prefs.setIntPref( - "network.proxy.type", - Ci.nsIProtocolProxyService.PROXYCONFIG_SYSTEM - ); - - let httpserv = new HttpServer(); - httpserv.registerPathHandler("/", function handler(metadata, response) { - let content = "ok"; - response.setHeader("Content-Length", `${content.length}`); - response.bodyOutputStream.write(content, content.length); - }); - httpserv.start(-1); - - Services.prefs.setBoolPref("network.dns.native-is-localhost", false); - Services.prefs.setIntPref("network.trr.mode", 0); // Disable TRR until the PAC is loaded - override.addIPOverride("example.org", "127.0.0.1"); - let chan = NetUtil.newChannel({ - uri: `http://example.org:${httpserv.identity.primaryPort}/`, - loadUsingSystemPrincipal: true, - }).QueryInterface(Ci.nsIHttpChannel); - await new Promise(resolve => chan.asyncOpen(new ChannelListener(resolve))); - await consolePromise; - - let env = Cc["@mozilla.org/process/environment;1"].getService( - Ci.nsIEnvironment - ); - let h2Port = env.get("MOZHTTP2_PORT"); - Assert.notEqual(h2Port, null); - Assert.notEqual(h2Port, ""); - - override.addIPOverride("foo.example.com", "127.0.0.1"); - Services.prefs.setCharPref( - "network.trr.uri", - `https://foo.example.com:${h2Port}/doh?responseIP=127.0.0.1` - ); - - async function test_with(DOMAIN, trrMode, fetchOffMainThread) { - Services.prefs.setIntPref("network.trr.mode", trrMode); // TRR first - Services.prefs.setBoolPref( - "network.trr.fetch_off_main_thread", - fetchOffMainThread - ); - override.addIPOverride(DOMAIN, "127.0.0.1"); - - chan = NetUtil.newChannel({ - uri: `http://${DOMAIN}:${httpserv.identity.primaryPort}/`, - loadUsingSystemPrincipal: true, - }).QueryInterface(Ci.nsIHttpChannel); - await new Promise(resolve => chan.asyncOpen(new ChannelListener(resolve))); - - await override.clearHostOverride(DOMAIN); - } - - await test_with("test1.com", 2, true); - await test_with("test2.com", 3, true); - await test_with("test3.com", 2, false); - await test_with("test4.com", 3, false); - await httpserv.stop(); -}); diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index 65869126349f..ac7a41c18a2d 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -433,4 +433,3 @@ skip-if = true || asan || tsan || os == 'win' || os =='android' [test_trr_httpssvc.js] [test_trr_case_sensitivity.js] skip-if = os == "android" || verify -[test_trr_proxy.js]