Bug 1638330 - Fix intermittent netwerk/test/unit/test_dns_disabled.js r=necko-reviewers,valentin
authorAlex Catarineu <acat@torproject.org>
Wed, 20 May 2020 10:27:44 +0000
changeset 531204 4a52971214a13aeb8d3279a240145318f04639c8
parent 531203 e4f5894fe3fa5bf14a35c3ff35ce40b315cc38c0
child 531205 e708c9a6b38fe26262ef3d3a7466b8fd0913b2d0
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnecko-reviewers, valentin
bugs1638330
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1638330 - Fix intermittent netwerk/test/unit/test_dns_disabled.js r=necko-reviewers,valentin Remove test case which relied on an entry being in the DNS cache, and was most likely the cause of the intermittent failures. Also added an assert to check the lookup result status before calling inRecord.getNextAddrAsString(), as that was resulting in a timeout instead of a test failure. Also some minor changes removing a few lines that were not needed. Differential Revision: https://phabricator.services.mozilla.com/D76097
netwerk/test/unit/test_dns_disabled.js
--- a/netwerk/test/unit/test_dns_disabled.js
+++ b/netwerk/test/unit/test_dns_disabled.js
@@ -14,32 +14,31 @@ var prefs = Cc["@mozilla.org/preferences
 var defaultOriginAttributes = {};
 
 function makeListenerBlock(next) {
   return {
     onLookupComplete(inRequest, inRecord, inStatus) {
       Assert.ok(!Components.isSuccessCode(inStatus));
       next();
     },
-    QueryInterface: ChromeUtils.generateQI(["nsIDNSListener"]),
   };
 }
 
 function makeListenerDontBlock(next, expectedAnswer) {
   return {
     onLookupComplete(inRequest, inRecord, inStatus) {
+      Assert.equal(inStatus, Cr.NS_OK);
       var answer = inRecord.getNextAddrAsString();
       if (expectedAnswer) {
         Assert.equal(answer, expectedAnswer);
       } else {
         Assert.ok(answer == "127.0.0.1" || answer == "::1");
       }
       next();
     },
-    QueryInterface: ChromeUtils.generateQI(["nsIDNSListener"]),
   };
 }
 
 function do_test({
   dnsDisabled,
   mustBlock,
   testDomain,
   nextCallback,
@@ -64,32 +63,22 @@ function do_test({
 
 function all_done() {
   // Reset locally modified prefs
   prefs.setCharPref("network.dns.localDomains", localdomainPref);
   prefs.setBoolPref("network.dns.disabled", disabledPref);
   do_test_finished();
 }
 
-// Cached hostnames should be resolved even if dns is disabled
-function testCached() {
-  do_test({
-    dnsDisabled: true,
-    mustBlock: false,
-    testDomain: "foo.bar",
-    nextCallback: all_done,
-  });
-}
-
 function testNotBlocked() {
   do_test({
     dnsDisabled: false,
     mustBlock: false,
     testDomain: "foo.bar",
-    nextCallback: testCached,
+    nextCallback: all_done,
   });
 }
 
 function testBlocked() {
   do_test({
     dnsDisabled: true,
     mustBlock: true,
     testDomain: "foo.bar",