Bug 1436213 - Make test_bug1274685_unowned_list.js work on pver2 and pver4. r=gcp
authorFrancois Marier <francois@mozilla.com>
Tue, 06 Feb 2018 15:36:48 -0800
changeset 403247 0cdfcf8734a9eeb40ff2d0f8a60fa05d8a56a6bb
parent 403246 474bea93396d7923707b9273b18f2189fe51ea07
child 403248 14128b25db9fab9e597935876a318ac927f21ef2
push id99755
push userbtara@mozilla.com
push dateSat, 10 Feb 2018 10:02:59 +0000
treeherdermozilla-inbound@0417e1acfc10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1436213
milestone60.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 1436213 - Make test_bug1274685_unowned_list.js work on pver2 and pver4. r=gcp This test is supposed to verify that Safe Browsing providers can be initialized correctly even when a table is not configured properly. By removing a table from both google and google4, we ensure that the test will be meaningful regardless of the stack in use. Also filter out the console noise triggered by looking for the update and gethash URLs of the "test" dummy provider. MozReview-Commit-ID: KjWqSqA4FxJ
toolkit/components/url-classifier/SafeBrowsing.jsm
toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js
--- a/toolkit/components/url-classifier/SafeBrowsing.jsm
+++ b/toolkit/components/url-classifier/SafeBrowsing.jsm
@@ -334,16 +334,19 @@ this.SafeBrowsing = {
         } else {
           providerStr += ", " + provider;
         }
       });
       log("Providers: " + providerStr);
     }
 
     Object.keys(this.providers).forEach(function(provider) {
+      if (provider == "test") {
+        return; // skip
+      }
       let updateURL = Services.urlFormatter.formatURLPref(
         "browser.safebrowsing.provider." + provider + ".updateURL");
       let gethashURL = Services.urlFormatter.formatURLPref(
         "browser.safebrowsing.provider." + provider + ".gethashURL");
       updateURL = updateURL.replace("SAFEBROWSING_ID", clientID);
       gethashURL = gethashURL.replace("SAFEBROWSING_ID", clientID);
 
       // Disable updates and gethash if the Google API key is missing.
--- a/toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js
+++ b/toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js
@@ -4,28 +4,31 @@ ChromeUtils.import("resource://testing-c
 // 'Cc["@mozilla.org/xre/app-info;1"]' for xpcshell has no nsIXULAppInfo
 // so that we have to update it to make nsURLFormatter.js happy.
 // (SafeBrowsing.init() will indirectly use nsURLFormatter.js)
 updateAppInfo();
 
 function run_test() {
   SafeBrowsing.init();
 
-  let origList = Services.prefs.getCharPref("browser.safebrowsing.provider.google.lists");
+  let origListV2 = Services.prefs.getCharPref("browser.safebrowsing.provider.google.lists");
+  let origListV4 = Services.prefs.getCharPref("browser.safebrowsing.provider.google4.lists");
 
-  // Remove 'goog-malware-shavar' from the original.
-  let trimmedList = origList.replace("goog-malware-shavar,", "");
-  Services.prefs.setCharPref("browser.safebrowsing.provider.google.lists", trimmedList);
+  // Ensure there's a list missing in both Safe Browsing V2 and V4.
+  let trimmedListV2 = origListV2.replace("goog-malware-shavar,", "");
+  Services.prefs.setCharPref("browser.safebrowsing.provider.google.lists", trimmedListV2);
+  let trimmedListV4 = origListV4.replace("goog-malware-proto,", "");
+  Services.prefs.setCharPref("browser.safebrowsing.provider.google4.lists", trimmedListV4);
 
   try {
     // Bug 1274685 - Unowned Safe Browsing tables break list updates
     //
     // If SafeBrowsing.registerTableWithURLs() doesn't check if
     // a provider is found before registering table, an exception
     // will be thrown while accessing a null object.
     //
     SafeBrowsing.registerTables();
   } catch (e) {
     ok(false, "Exception thrown due to " + e.toString());
   }
-
-  Services.prefs.setCharPref("browser.safebrowsing.provider.google.lists", origList);
+  Services.prefs.clearUserPref("browser.safebrowsing.provider.google.lists");
+  Services.prefs.clearUserPref("browser.safebrowsing.provider.google4.lists");
 }