Bug 1237396 - Add safebrowsing test for initial download of files. r?whimboo draft
authorBenjamin Forehand Jr <bennyjr169@gmail.com>
Wed, 09 Mar 2016 17:19:35 -0500
changeset 344562 f829674871f5c4abcee6bdcf8d8ba41104f36c86
parent 343376 ea6298e1b4f7e22ce2311b2b6a918822f0adb112
child 516985 ce1fcb8eddda6ae935d8aa13a8f47c0f7caf696a
push id13858
push userbmo:bennyjr169@gmail.com
push dateThu, 24 Mar 2016 20:42:08 +0000
reviewerswhimboo
bugs1237396
milestone48.0a1
Bug 1237396 - Add safebrowsing test for initial download of files. r?whimboo Added additional browser preference and finalized setting of the preferences according to francois. MozReview-Commit-ID: J3u5LNy6lpH
testing/firefox-ui/tests/functional/security/manifest.ini
testing/firefox-ui/tests/functional/security/test_safe_browsing_initial_download.py
--- a/testing/firefox-ui/tests/functional/security/manifest.ini
+++ b/testing/firefox-ui/tests/functional/security/manifest.ini
@@ -4,16 +4,17 @@ tags = remote
 [test_dv_certificate.py]
 [test_enable_privilege.py]
 tags = local
 [test_ev_certificate.py]
 [test_mixed_content_page.py]
 [test_mixed_script_content_blocking.py]
 [test_no_certificate.py]
 tags = local
+[test_safe_browsing_initial_download.py]
 [test_safe_browsing_notification.py]
 [test_safe_browsing_warning_pages.py]
 [test_security_notification.py]
 [test_ssl_disabled_error_page.py]
 [test_ssl_status_after_restart.py]
 skip-if = (os == "win" && os_version == "5.1") # Bug 1167179: Fails to open popups after restart
 [test_submit_unencrypted_info_warning.py]
 [test_unknown_issuer.py]
new file mode 100644
--- /dev/null
+++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_initial_download.py
@@ -0,0 +1,80 @@
+# 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/.
+
+import os
+
+from firefox_puppeteer.testcases import FirefoxTestCase
+from marionette_driver import Wait
+
+
+class TestSafeBrowsingInitialDownload(FirefoxTestCase):
+
+    test_data = [{
+            'platforms': ['linux', 'windows_nt', 'darwin'],
+            'files': [
+                # Phishing
+                "goog-badbinurl-shavar.cache",
+                "goog-badbinurl-shavar.pset",
+                "goog-badbinurl-shavar.sbstore",
+                "goog-malware-shavar.cache",
+                "goog-malware-shavar.pset",
+                "goog-malware-shavar.sbstore",
+                "goog-phish-shavar.cache",
+                "goog-phish-shavar.pset",
+                "goog-phish-shavar.sbstore",
+                "goog-unwanted-shavar.cache",
+                "goog-unwanted-shavar.pset",
+                "goog-unwanted-shavar.sbstore",
+
+                # Tracking Protections
+                "mozstd-track-digest256.cache",
+                "mozstd-track-digest256.pset",
+                "mozstd-track-digest256.sbstore",
+                "mozstd-trackwhite-digest256.cache",
+                "mozstd-trackwhite-digest256.pset",
+                "mozstd-trackwhite-digest256.sbstore"
+                ]
+            },
+        {
+            'platforms': ['windows_nt'],
+            'files': [
+                "goog-downloadwhite-digest256.cache",
+                "goog-downloadwhite-digest256.pset",
+                "goog-downloadwhite-digest256.sbstore"
+            ]
+        }
+    ]
+
+    browser_prefs = {
+        'browser.safebrowsing.downloads.enabled': 'true',
+        'browser.safebrowsing.enabled': 'true',
+        'browser.safebrowsing.malware.enabled': 'true',
+        'browser.safebrowsing.provider.google.nextupdatetime': 1,
+        'browser.safebrowsing.provider.mozilla.nextupdatetime': 1,
+        'privacy.trackingprotection.enabled': 'true'
+    }
+
+    def setUp(self):
+        FirefoxTestCase.setUp(self)
+
+        # Restart Browser
+        self.restart()
+
+        # Set Browser Preferences
+        for item, value in self.browser_prefs.items():
+            self.prefs.set_pref(item, value)
+
+        # Get safebrowsing path where downloaded data gets stored
+        self.sb_files_path = os.path.join(self.marionette.instance.profile.profile, 'safebrowsing')
+
+    def test_safe_browsing_initial_download(self):
+        wait = Wait(self.marionette, timeout=self.browser.timeout_page_load)
+
+        for data in self.test_data:
+            if self.platform not in data['platforms']:
+                continue
+            for item in data['files']:
+                wait.until(
+                    lambda _: os.path.exists(os.path.join(self.sb_files_path, item)),
+                    message='Safe Browsing File: {} not found!'.format(item))