Bug 1357372 - Restrict safebrowsing tests from reaching support.mozilla.org draft
authorRaajit Raj <raajit.raj@gmail.com>
Thu, 11 May 2017 23:02:42 +0530
changeset 576400 cbf77a00c3319d0ebd596ff570729787204a12b1
parent 576334 3b96f277325747fe668ca8cd896d2f581238e4ee
child 628195 97c72f9b70bab38d100f05d1825fb6a1d98b9b44
push id58359
push userbmo:raajit.raj@gmail.com
push dateThu, 11 May 2017 18:23:32 +0000
bugs1357372
milestone55.0a1
Bug 1357372 - Restrict safebrowsing tests from reaching support.mozilla.org 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))