Bug 1357372 - Restrict safebrowsing tests from reaching support.mozilla.org. r=whimboo, a=test-only
authorRaajit Raj <raajit.raj@gmail.com>
Thu, 11 May 2017 23:02:42 +0530
changeset 396307 1a5b19210b16026513ada54a4e0db4f038876bb4
parent 396306 57782b6323abae342864c4a29bb802decb7914fe
child 396308 444be25337e3b9de1e5cdb0a4a0a6799c065a4ce
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo, test-only
bugs1357372
milestone54.0
Bug 1357372 - Restrict safebrowsing tests from reaching support.mozilla.org. r=whimboo, a=test-only MozReview-Commit-ID: 1P36My7AxpY
testing/firefox-ui/resources/support.html
testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
new file mode 100644
--- /dev/null
+++ b/testing/firefox-ui/resources/support.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+  <script type="text/javascript">
+    function show() {
+      var results = /\?topic=(.+)$/.exec(window.document.location);
+      var topic = decodeURIComponent(results[1].replace(/\+/g, " "))
+      var node = document.getElementById("topic");
+
+      node.textContent = topic;
+    }
+  </script>
+</head>
+
+<body onload="show()">
+  <div id="topic"></div>
+</body>
+</html>
--- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
+++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
@@ -18,32 +18,35 @@ class TestSafeBrowsingWarningPages(Puppe
             # Unwanted software URL
             'https://www.itisatrap.org/firefox/unwanted.html',
             # Phishing URL
             'https://www.itisatrap.org/firefox/its-a-trap.html',
             # Malware URL
             'https://www.itisatrap.org/firefox/its-an-attack.html'
         ]
 
+        self.marionette.set_pref('app.support.baseURL',
+                                 self.marionette.absolute_url("support.html?topic="))
         self.marionette.set_pref('browser.safebrowsing.phishing.enabled', True)
         self.marionette.set_pref('browser.safebrowsing.malware.enabled', True)
 
         # Give the browser a little time, because SafeBrowsing.jsm takes a
         # while between start up and adding the example urls to the db.
         # hg.mozilla.org/mozilla-central/file/46aebcd9481e/browser/base/content/browser.js#l1194
         time.sleep(3)
 
         # TODO: Bug 1139544: While we don't have a reliable way to close the safe browsing
         # notification bar when a test fails, run this test in a new tab.
         self.browser.tabbar.open_tab()
 
     def tearDown(self):
         try:
             self.puppeteer.utils.permissions.remove('https://www.itisatrap.org', 'safe-browsing')
             self.browser.tabbar.close_all_tabs([self.browser.tabbar.tabs[0]])
+            self.marionette.clear_pref('app.support.baseURL')
             self.marionette.clear_pref('browser.safebrowsing.malware.enabled')
             self.marionette.clear_pref('browser.safebrowsing.phishing.enabled')
         finally:
             super(TestSafeBrowsingWarningPages, self).tearDown()
 
     def test_warning_pages(self):
         with self.marionette.using_context("content"):
             for unsafe_page in self.urls:
@@ -92,16 +95,19 @@ class TestSafeBrowsingWarningPages(Puppe
         # Wait for page load to be completed, so we can verify the URL even if a redirect happens.
         # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
         expected_url = self.browser.get_final_url(url)
         Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
             lambda mn: expected_url == mn.get_url(),
             message="The expected URL '{}' has not been loaded".format(expected_url)
         )
 
+        topic = self.marionette.find_element(By.ID, "topic")
+        self.assertEquals(topic.text, "phishing-malware")
+
     def check_ignore_warning_button(self, unsafe_page):
         button = self.marionette.find_element(By.ID, 'ignoreWarningButton')
         button.click()
 
         Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
             expected.element_present(By.ID, 'main-feature'))
         self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(unsafe_page))