Bug 1357372 - Restrict safebrowsing tests from reaching support.mozilla.org
MozReview-Commit-ID: 1P36My7AxpY
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))