Backed out changeset 901b3eec4eb6 (bug 1618130) for xpcshell failures at netwerk/test/unit/test_dns_override.js on a CLOSED TREE
authorCoroiu Cristina <ccoroiu@mozilla.com>
Wed, 26 Feb 2020 18:25:03 +0200
changeset 515669 862da1751d9fb10d1daa20940ffa722c888078b1
parent 515668 c230c87ea4414402b1e803ee965422310815f69b
child 515670 70d1596f7beb256a92cfa4e67aa9c1538568b67f
push id37160
push useraciure@mozilla.com
push dateWed, 26 Feb 2020 21:39:03 +0000
treeherdermozilla-central@862da1751d9f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1618130
milestone75.0a1
backs out901b3eec4eb6757da5558b3bd80eb8aa61eb61bc
first release with
nightly linux32
862da1751d9f / 75.0a1 / 20200226213903 / files
nightly linux64
862da1751d9f / 75.0a1 / 20200226213903 / files
nightly mac
862da1751d9f / 75.0a1 / 20200226213903 / files
nightly win32
862da1751d9f / 75.0a1 / 20200226213903 / files
nightly win64
862da1751d9f / 75.0a1 / 20200226213903 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 901b3eec4eb6 (bug 1618130) for xpcshell failures at netwerk/test/unit/test_dns_override.js on a CLOSED TREE
netwerk/build/components.conf
netwerk/dns/GetAddrInfo.cpp
netwerk/dns/GetAddrInfo.h
netwerk/dns/moz.build
netwerk/dns/nsINativeDNSResolverOverride.idl
netwerk/test/unit/test_dns_override.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/build/components.conf
+++ b/netwerk/build/components.conf
@@ -108,25 +108,16 @@ Classes = [
         'contract_ids': ['@mozilla.org/network/dns-service;1'],
         'singleton': True,
         'type': 'nsIDNSService',
         'constructor': 'nsDNSService::GetXPCOMSingleton',
         'headers': ['/netwerk/dns/nsDNSService2.h'],
         'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
     },
     {
-        'cid': '{4ffae79e-57bd-4d7a-a0c9-0045a17b3615}',
-        'contract_ids': ['@mozilla.org/network/native-dns-override;1'],
-        'singleton': True,
-        'type': 'nsINativeDNSResolverOverride',
-        'constructor': 'mozilla::net::NativeDNSResolverOverride::GetSingleton',
-        'headers': ['/netwerk/dns/GetAddrInfo.h'],
-        'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
-    },
-    {
         'cid': '{510a86bb-6019-4ed1-bb4f-965cffd23ece}',
         'contract_ids': ['@mozilla.org/network/downloader;1'],
         'type': 'nsDownloader',
         'headers': ['/netwerk/base/nsDownloader.h'],
     },
     {
         'cid': '{cb9abbae-66b6-4609-8594-5c4ff300888e}',
         'contract_ids': ['@mozilla.org/network/effective-tld-service;1'],
--- a/netwerk/dns/GetAddrInfo.cpp
+++ b/netwerk/dns/GetAddrInfo.cpp
@@ -24,18 +24,16 @@
 #  include <ws2tcpip.h>
 #  undef GetAddrInfo
 #  include <windns.h>
 #endif
 
 namespace mozilla {
 namespace net {
 
-static StaticRefPtr<NativeDNSResolverOverride> gOverrideService;
-
 static LazyLogModule gGetAddrInfoLog("GetAddrInfo");
 #define LOG(msg, ...) \
   MOZ_LOG(gGetAddrInfoLog, LogLevel::Debug, ("[DNS]: " msg, ##__VA_ARGS__))
 #define LOG_WARNING(msg, ...) \
   MOZ_LOG(gGetAddrInfoLog, LogLevel::Warning, ("[DNS]: " msg, ##__VA_ARGS__))
 
 #ifdef DNSQUERY_AVAILABLE
 ////////////////////////////
@@ -183,70 +181,29 @@ nsresult GetAddrInfoInit() {
   return NS_OK;
 }
 
 nsresult GetAddrInfoShutdown() {
   LOG("Shutting down GetAddrInfo.\n");
   return NS_OK;
 }
 
-bool FindAddrOverride(const nsACString& aHost, uint16_t aAddressFamily,
-                      uint16_t aFlags, AddrInfo** aAddrInfo) {
-  RefPtr<NativeDNSResolverOverride> overrideService = gOverrideService;
-  if (!overrideService) {
-    return false;
-  }
-  AutoReadLock lock(overrideService->mLock);
-  nsTArray<PRNetAddr>* overrides = overrideService->mOverrides.GetValue(aHost);
-  if (!overrides) {
-    return false;
-  }
-  nsCString* cname = nullptr;
-  if (aFlags & nsHostResolver::RES_CANON_NAME) {
-    cname = overrideService->mCnames.GetValue(aHost);
-  }
-
-  RefPtr<AddrInfo> ai;
-
-  if (!cname) {
-    ai = new AddrInfo(aHost, 0);
-  } else {
-    ai = new AddrInfo(aHost, *cname, 0);
-  }
-
-  for (const auto& ip : *overrides) {
-    if (aAddressFamily != AF_UNSPEC && ip.raw.family != aAddressFamily) {
-      continue;
-    }
-    ai->AddAddress(new NetAddrElement(&ip));
-  }
-
-  ai.forget(aAddrInfo);
-  return true;
-}
-
 nsresult GetAddrInfo(const nsACString& aHost, uint16_t aAddressFamily,
                      uint16_t aFlags, AddrInfo** aAddrInfo, bool aGetTtl) {
   if (NS_WARN_IF(aHost.IsEmpty()) || NS_WARN_IF(!aAddrInfo)) {
     return NS_ERROR_NULL_POINTER;
   }
 
 #ifdef DNSQUERY_AVAILABLE
   // The GetTTLData needs the canonical name to function properly
   if (aGetTtl) {
     aFlags |= nsHostResolver::RES_CANON_NAME;
   }
 #endif
 
-  // If there is an override for this host, then we synthetize a result.
-  if (gOverrideService &&
-      FindAddrOverride(aHost, aAddressFamily, aFlags, aAddrInfo)) {
-    return NS_OK;
-  }
-
   nsAutoCString host(aHost);
   if (gNativeIsLocalhost) {
     // pretend we use the given host but use IPv4 localhost instead!
     host = NS_LITERAL_CSTRING("localhost");
     aAddressFamily = PR_AF_INET;
   }
 
   *aAddrInfo = nullptr;
@@ -274,75 +231,10 @@ nsresult GetAddrInfo(const nsACString& a
                   name.get());
     }
   }
 #endif
 
   return rv;
 }
 
-// static
-already_AddRefed<nsINativeDNSResolverOverride>
-NativeDNSResolverOverride::GetSingleton() {
-  if (gOverrideService) {
-    return do_AddRef(gOverrideService);
-  }
-
-  gOverrideService = new NativeDNSResolverOverride();
-  ClearOnShutdown(&gOverrideService);
-  return do_AddRef(gOverrideService);
-}
-
-NS_IMPL_ISUPPORTS(NativeDNSResolverOverride, nsINativeDNSResolverOverride)
-
-NS_IMETHODIMP NativeDNSResolverOverride::AddIPOverride(
-    const nsACString& aHost, const nsACString& aIPLiteral) {
-  PRNetAddr tempAddr;
-  // Unfortunately, PR_StringToNetAddr does not properly initialize
-  // the output buffer in the case of IPv6 input. See bug 223145.
-  memset(&tempAddr, 0, sizeof(PRNetAddr));
-
-  if (PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
-      PR_SUCCESS) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  AutoWriteLock lock(mLock);
-  auto& overrides = mOverrides.GetOrInsert(aHost);
-  overrides.AppendElement(tempAddr);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP NativeDNSResolverOverride::SetCnameOverride(
-    const nsACString& aHost, const nsACString& aCNAME) {
-  if (aCNAME.IsEmpty()) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  AutoWriteLock lock(mLock);
-  mCnames.Put(aHost, nsCString(aCNAME));
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP NativeDNSResolverOverride::ClearHostOverride(
-    const nsACString& aHost) {
-  AutoWriteLock lock(mLock);
-  mCnames.Remove(aHost);
-  auto overrides = mOverrides.GetAndRemove(aHost);
-  if (!overrides) {
-    return NS_OK;
-  }
-
-  overrides->Clear();
-  return NS_OK;
-}
-
-NS_IMETHODIMP NativeDNSResolverOverride::ClearOverrides() {
-  AutoWriteLock lock(mLock);
-  mOverrides.Clear();
-  mCnames.Clear();
-  return NS_OK;
-}
-
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/dns/GetAddrInfo.h
+++ b/netwerk/dns/GetAddrInfo.h
@@ -4,20 +4,16 @@
  * 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/. */
 
 #ifndef netwerk_dns_GetAddrInfo_h
 #define netwerk_dns_GetAddrInfo_h
 
 #include "nsError.h"
 #include "nscore.h"
-#include "nsINativeDNSResolverOverride.h"
-#include "nsHashKeys.h"
-#include "nsDataHashtable.h"
-#include "mozilla/RWLock.h"
 
 #if defined(XP_WIN)
 #  define DNSQUERY_AVAILABLE 1
 #else
 #  undef DNSQUERY_AVAILABLE
 #endif
 
 namespace mozilla {
@@ -55,31 +51,12 @@ nsresult GetAddrInfoInit();
  * Shutdown the GetAddrInfo module.
  *
  * This function should be called for every time GetAddrInfoInit() is called.
  * An assertion may throw (but is not guarenteed) if this function is called
  * too many times.
  */
 nsresult GetAddrInfoShutdown();
 
-class NativeDNSResolverOverride : public nsINativeDNSResolverOverride {
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSINATIVEDNSRESOLVEROVERRIDE
- public:
-  NativeDNSResolverOverride() : mLock("NativeDNSResolverOverride") {}
-
-  static already_AddRefed<nsINativeDNSResolverOverride> GetSingleton();
-
- private:
-  virtual ~NativeDNSResolverOverride() = default;
-  mozilla::RWLock mLock;
-
-  nsDataHashtable<nsCStringHashKey, nsTArray<PRNetAddr>> mOverrides;
-  nsDataHashtable<nsCStringHashKey, nsCString> mCnames;
-
-  friend bool FindAddrOverride(const nsACString& aHost, uint16_t aAddressFamily,
-                               uint16_t aFlags, AddrInfo** aAddrInfo);
-};
-
 }  // namespace net
 }  // namespace mozilla
 
 #endif  // netwerk_dns_GetAddrInfo_h
--- a/netwerk/dns/moz.build
+++ b/netwerk/dns/moz.build
@@ -14,17 +14,16 @@ DIRS += [
 
 XPIDL_SOURCES += [
     'nsIDNSByTypeRecord.idl',
     'nsIDNSListener.idl',
     'nsIDNSRecord.idl',
     'nsIDNSService.idl',
     'nsIEffectiveTLDService.idl',
     'nsIIDNService.idl',
-    'nsINativeDNSResolverOverride.idl',
     'nsPIDNSService.idl',
 ]
 
 XPIDL_MODULE = 'necko_dns'
 
 EXTRA_JS_MODULES['netwerk-dns'] += [
     'PublicSuffixList.jsm',
 ]
deleted file mode 100644
--- a/netwerk/dns/nsINativeDNSResolverOverride.idl
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 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/. */
-
-#include "nsISupports.idl"
-
-[scriptable, builtinclass, uuid(8e38d536-5501-48c0-a412-6c450040c8c8)]
-interface nsINativeDNSResolverOverride : nsISupports
-{
-  /**
-   * Adds an IP override for this specific host.
-   */
-  void addIPOverride(in AUTF8String aHost, in ACString aIPLiteral);
-
-  /**
-   * Sets a CNAME override for this specific host.
-   */
-  void setCnameOverride(in AUTF8String aHost, in ACString aCNAME);
-
-  /**
-   * Clears the overrides for this specific host
-   */
-  void clearHostOverride(in AUTF8String aHost);
-
-  /**
-   * Clears all the host overrides that were previously set.
-   */
-  void clearOverrides();
-};
deleted file mode 100644
--- a/netwerk/test/unit/test_dns_override.js
+++ /dev/null
@@ -1,271 +0,0 @@
-"use strict";
-
-const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
-  Ci.nsIDNSService
-);
-const override = Cc["@mozilla.org/network/native-dns-override;1"].getService(
-  Ci.nsINativeDNSResolverOverride
-);
-const defaultOriginAttributes = {};
-const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
-  Ci.nsIThreadManager
-);
-const mainThread = threadManager.currentThread;
-
-class Listener {
-  constructor() {
-    this.promise = new Promise(resolve => {
-      this.resolve = resolve;
-    });
-  }
-
-  onLookupComplete(inRequest, inRecord, inStatus) {
-    this.resolve([inRequest, inRecord, inStatus]);
-  }
-
-  async firstAddress() {
-    let all = await this.addresses();
-    return all[0];
-  }
-
-  async addresses() {
-    let [inRequest, inRecord, inStatus] = await this.promise;
-    let addresses = [];
-    while (inRecord.hasMore()) {
-      addresses.push(inRecord.getNextAddrAsString());
-    }
-    return addresses;
-  }
-
-  then() {
-    return this.promise.then.apply(this.promise, arguments);
-  }
-}
-Listener.prototype.QueryInterface = ChromeUtils.generateQI(["nsIDNSListener"]);
-
-add_task(async function test_bad_IPs() {
-  Assert.throws(
-    () => override.addIPOverride("test.com", "test.com"),
-    /NS_ERROR_UNEXPECTED/,
-    "Should throw if input is not an IP address"
-  );
-  Assert.throws(
-    () => override.addIPOverride("test.com", ""),
-    /NS_ERROR_UNEXPECTED/,
-    "Should throw if input is not an IP address"
-  );
-  Assert.throws(
-    () => override.addIPOverride("test.com", " "),
-    /NS_ERROR_UNEXPECTED/,
-    "Should throw if input is not an IP address"
-  );
-  Assert.throws(
-    () => override.addIPOverride("test.com", "1-2-3-4"),
-    /NS_ERROR_UNEXPECTED/,
-    "Should throw if input is not an IP address"
-  );
-});
-
-add_task(async function test_ipv4() {
-  let listener = new Listener();
-  override.addIPOverride("test.com", "1.2.3.4");
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.equal(await listener.firstAddress(), "1.2.3.4");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_ipv6() {
-  let listener = new Listener();
-  override.addIPOverride("test.com", "fe80::6a99:9b2b:6ccc:6e1b");
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.equal(await listener.firstAddress(), "fe80::6a99:9b2b:6ccc:6e1b");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_clearOverrides() {
-  let listener = new Listener();
-  override.addIPOverride("test.com", "1.2.3.4");
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.equal(await listener.firstAddress(), "1.2.3.4");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-
-  listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.notEqual(await listener.firstAddress(), "1.2.3.4");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_clearHostOverride() {
-  override.addIPOverride("test.com", "2.2.2.2");
-  override.addIPOverride("example.com", "2.2.2.2");
-  override.clearHostOverride("test.com");
-  let listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.notEqual(await listener.firstAddress(), "2.2.2.2");
-
-  listener = new Listener();
-  dns.asyncResolve(
-    "example.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.equal(await listener.firstAddress(), "2.2.2.2");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_multiple_IPs() {
-  override.addIPOverride("test.com", "2.2.2.2");
-  override.addIPOverride("test.com", "1.1.1.1");
-  override.addIPOverride("test.com", "::1");
-  override.addIPOverride("test.com", "fe80::6a99:9b2b:6ccc:6e1b");
-  let listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.deepEqual(await listener.addresses(), [
-    "2.2.2.2",
-    "1.1.1.1",
-    "::1",
-    "fe80::6a99:9b2b:6ccc:6e1b",
-  ]);
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_address_family_flags() {
-  override.addIPOverride("test.com", "2.2.2.2");
-  override.addIPOverride("test.com", "1.1.1.1");
-  override.addIPOverride("test.com", "::1");
-  override.addIPOverride("test.com", "fe80::6a99:9b2b:6ccc:6e1b");
-  let listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.deepEqual(await listener.addresses(), [
-    "::1",
-    "fe80::6a99:9b2b:6ccc:6e1b",
-  ]);
-
-  listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    Ci.nsIDNSService.RESOLVE_DISABLE_IPV6,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  Assert.deepEqual(await listener.addresses(), ["2.2.2.2", "1.1.1.1"]);
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
-
-add_task(async function test_cname_flag() {
-  override.addIPOverride("test.com", "2.2.2.2");
-  let listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    0,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  let [inRequest, inRecord, inStatus] = await listener;
-  Assert.throws(
-    () => inRecord.canonicalName,
-    /NS_ERROR_NOT_AVAILABLE/,
-    "No canonical name flag"
-  );
-  Assert.equal(inRecord.getNextAddrAsString(), "2.2.2.2");
-
-  listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  [inRequest, inRecord, inStatus] = await listener;
-  Assert.equal(
-    inRecord.canonicalName,
-    "test.com",
-    "No canonical name specified"
-  );
-  Assert.equal(inRecord.getNextAddrAsString(), "2.2.2.2");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-
-  override.addIPOverride("test.com", "2.2.2.2");
-  override.setCnameOverride("test.com", "example.com");
-  listener = new Listener();
-  dns.asyncResolve(
-    "test.com",
-    Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
-    listener,
-    mainThread,
-    defaultOriginAttributes
-  );
-  [inRequest, inRecord, inStatus] = await listener;
-  Assert.equal(
-    inRecord.canonicalName,
-    "example.com",
-    "Must have correct CNAME"
-  );
-  Assert.equal(inRecord.getNextAddrAsString(), "2.2.2.2");
-
-  dns.clearCache(false);
-  override.clearOverrides();
-});
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -413,9 +413,8 @@ skip-if = os == "android"
 [test_head_request_no_response_body.js]
 [test_disabled_ftp.js]
 [test_cache_204_response.js]
 [test_node_execute.js]
 [test_loadgroup_cancel.js]
 [test_obs-fold.js]
 [test_defaultURI.js]
 [test_port_remapping.js]
-[test_dns_override.js]