Bug 1371923 - Only check safebrowsing files when they are in preference in test_safe_browsing_initial_download.py. r?francois draft
authordimi <dlee@mozilla.com>
Mon, 19 Jun 2017 10:19:02 +0800
changeset 597024 0a44e0e243164d330f07dd9ad971bca0208f27d5
parent 597021 bc9e028dbdc5c2f989175e6816dc864159133aee
child 634105 942ad90524b014e0e5f0050667d95cf72b7eba46
push id64795
push userbmo:dlee@mozilla.com
push dateTue, 20 Jun 2017 00:37:38 +0000
reviewersfrancois
bugs1371923
milestone56.0a1
Bug 1371923 - Only check safebrowsing files when they are in preference in test_safe_browsing_initial_download.py. r?francois Ensure that we only wait for the providers that are enabled (i.e. have active lists) to avoid waiting forever and timing out. In order to check whether or not the google and google4 providers are enabled, we look for lists that start with "goog" in both the V2 files and the V4 files. We use 'goog' here instead of 'goog-' because there are both 'goog-xxx-xxx' and 'googpub-xxx-xxx' tables MozReview-Commit-ID: 72JWZRs3Qxd
testing/firefox-ui/tests/functional/security/test_safe_browsing_initial_download.py
--- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_initial_download.py
+++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_initial_download.py
@@ -28,17 +28,16 @@ class TestSafeBrowsingInitialDownload(Pu
         'urlclassifier.malwareTable',
         'urlclassifier.phishTable',
         'urlclassifier.trackingTable',
         'urlclassifier.trackingWhitelistTable',
     ]
 
     prefs_provider_update_time = {
         # Force an immediate download of the safebrowsing files
-        'browser.safebrowsing.provider.google4.nextupdatetime': 1,
         'browser.safebrowsing.provider.mozilla.nextupdatetime': 1,
     }
 
     prefs_safebrowsing = {
         'browser.safebrowsing.debug': True,
         'browser.safebrowsing.blockedURIs.enabled': True,
         'browser.safebrowsing.downloads.enabled': True,
         'browser.safebrowsing.phishing.enabled': True,
@@ -61,25 +60,35 @@ class TestSafeBrowsingInitialDownload(Pu
                 files.extend(['{name}.{ext}'.format(name=f, ext=ext)
                               for f in base_names if f and f.endswith('-proto') == is_v4])
 
         return set(sorted(files))
 
     def setUp(self):
         super(TestSafeBrowsingInitialDownload, self).setUp()
 
+        self.safebrowsing_v2_files = self.get_safebrowsing_files(False)
+        if any(f.startswith('goog') for f in self.safebrowsing_v2_files):
+            self.prefs_provider_update_time.update({
+                'browser.safebrowsing.provider.google.nextupdatetime': 1,
+            })
+
+        self.safebrowsing_v4_files = self.get_safebrowsing_files(True)
+        if any(f.startswith('goog') for f in self.safebrowsing_v4_files):
+            self.prefs_provider_update_time.update({
+                'browser.safebrowsing.provider.google4.nextupdatetime': 1,
+            })
+
         # Force the preferences for the new profile
         enforce_prefs = self.prefs_safebrowsing
         enforce_prefs.update(self.prefs_provider_update_time)
         self.marionette.enforce_gecko_prefs(enforce_prefs)
 
         self.safebrowsing_path = os.path.join(self.marionette.instance.profile.profile,
                                               'safebrowsing')
-        self.safebrowsing_v2_files = self.get_safebrowsing_files(False)
-        self.safebrowsing_v4_files = self.get_safebrowsing_files(True)
 
     def tearDown(self):
         try:
             # Restart with a fresh profile
             self.restart(clean=True)
         finally:
             super(TestSafeBrowsingInitialDownload, self).tearDown()