diff options
Diffstat (limited to 'browser/components/safebrowsing')
6 files changed, 0 insertions, 255 deletions
diff --git a/browser/components/safebrowsing/content/test/.eslintrc.js b/browser/components/safebrowsing/content/test/.eslintrc.js deleted file mode 100644 index 7c8021192..000000000 --- a/browser/components/safebrowsing/content/test/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "../../../../../testing/mochitest/browser.eslintrc.js" - ] -}; diff --git a/browser/components/safebrowsing/content/test/browser.ini b/browser/components/safebrowsing/content/test/browser.ini deleted file mode 100644 index 1ce19118e..000000000 --- a/browser/components/safebrowsing/content/test/browser.ini +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -support-files = head.js - -[browser_bug400731.js] -[browser_bug415846.js] -# Disabled on Mac because of its bizarre special-and-unique snowflake of a help menu. -skip-if = os == "mac" || e10s # e10s: Bug 1248632 -[browser_whitelisted.js] diff --git a/browser/components/safebrowsing/content/test/browser_bug400731.js b/browser/components/safebrowsing/content/test/browser_bug400731.js deleted file mode 100644 index fac187753..000000000 --- a/browser/components/safebrowsing/content/test/browser_bug400731.js +++ /dev/null @@ -1,58 +0,0 @@ -/* Check presence of the "Ignore this warning" button */ - -function onDOMContentLoaded(callback) { - function complete({ data }) { - mm.removeMessageListener("Test:DOMContentLoaded", complete); - callback(data); - } - - let mm = gBrowser.selectedBrowser.messageManager; - mm.addMessageListener("Test:DOMContentLoaded", complete); - - function contentScript() { - let listener = function () { - removeEventListener("DOMContentLoaded", listener); - - let button = content.document.getElementById("ignoreWarningButton"); - - sendAsyncMessage("Test:DOMContentLoaded", { buttonPresent: !!button }); - }; - addEventListener("DOMContentLoaded", listener); - } - mm.loadFrameScript("data:,(" + contentScript.toString() + ")();", true); -} - -function test() { - waitForExplicitFinish(); - - gBrowser.selectedTab = gBrowser.addTab("http://www.itisatrap.org/firefox/its-an-attack.html"); - onDOMContentLoaded(testMalware); -} - -function testMalware(data) { - ok(data.buttonPresent, "Ignore warning button should be present for malware"); - - Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false); - - // Now launch the unwanted software test - onDOMContentLoaded(testUnwanted); - gBrowser.loadURI("http://www.itisatrap.org/firefox/unwanted.html"); -} - -function testUnwanted(data) { - // Confirm that "Ignore this warning" is visible - bug 422410 - ok(!data.buttonPresent, "Ignore warning button should be missing for unwanted software"); - - Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true); - - // Now launch the phishing test - onDOMContentLoaded(testPhishing); - gBrowser.loadURI("http://www.itisatrap.org/firefox/its-a-trap.html"); -} - -function testPhishing(data) { - ok(data.buttonPresent, "Ignore warning button should be present for phishing"); - - gBrowser.removeCurrentTab(); - finish(); -} diff --git a/browser/components/safebrowsing/content/test/browser_bug415846.js b/browser/components/safebrowsing/content/test/browser_bug415846.js deleted file mode 100644 index fc2e3472f..000000000 --- a/browser/components/safebrowsing/content/test/browser_bug415846.js +++ /dev/null @@ -1,86 +0,0 @@ -/* Check for the correct behaviour of the report web forgery/not a web forgery -menu items. - -Mac makes this astonishingly painful to test since their help menu is special magic, -but we can at least test it on the other platforms.*/ - -const NORMAL_PAGE = "http://example.com"; -const PHISH_PAGE = "http://www.itisatrap.org/firefox/its-a-trap.html"; - -/** - * Opens a new tab and browses to some URL, tests for the existence - * of the phishing menu items, and then runs a test function to check - * the state of the menu once opened. This function will take care of - * opening and closing the menu. - * - * @param url (string) - * The URL to browse the tab to. - * @param testFn (function) - * The function to run once the menu has been opened. This - * function will be passed the "reportMenu" and "errorMenu" - * DOM nodes as arguments, in that order. This function - * should not yield anything. - * @returns Promise - */ -function check_menu_at_page(url, testFn) { - return BrowserTestUtils.withNewTab({ - gBrowser, - url: "about:blank", - }, function*(browser) { - // We don't get load events when the DocShell redirects to error - // pages, but we do get DOMContentLoaded, so we'll wait for that. - let dclPromise = ContentTask.spawn(browser, null, function*() { - yield ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", false); - }); - browser.loadURI(url); - yield dclPromise; - - let menu = document.getElementById("menu_HelpPopup"); - ok(menu, "Help menu should exist"); - - let reportMenu = - document.getElementById("menu_HelpPopup_reportPhishingtoolmenu"); - ok(reportMenu, "Report phishing menu item should exist"); - - let errorMenu = - document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu"); - ok(errorMenu, "Report phishing error menu item should exist"); - - let menuOpen = BrowserTestUtils.waitForEvent(menu, "popupshown"); - menu.openPopup(null, "", 0, 0, false, null); - yield menuOpen; - - testFn(reportMenu, errorMenu); - - let menuClose = BrowserTestUtils.waitForEvent(menu, "popuphidden"); - menu.hidePopup(); - yield menuClose; - }); -} - -/** - * Tests that we show the "Report this page" menu item at a normal - * page. - */ -add_task(function*() { - yield check_menu_at_page(NORMAL_PAGE, (reportMenu, errorMenu) => { - ok(!reportMenu.hidden, - "Report phishing menu should be visible on normal sites"); - ok(errorMenu.hidden, - "Report error menu item should be hidden on normal sites"); - }); -}); - -/** - * Tests that we show the "Report this page is okay" menu item at - * a reported attack site. - */ -add_task(function*() { - yield check_menu_at_page(PHISH_PAGE, (reportMenu, errorMenu) => { - ok(reportMenu.hidden, - "Report phishing menu should be hidden on phishing sites"); - ok(!errorMenu.hidden, - "Report error menu item should be visible on phishing sites"); - }); -}); - diff --git a/browser/components/safebrowsing/content/test/browser_whitelisted.js b/browser/components/safebrowsing/content/test/browser_whitelisted.js deleted file mode 100644 index afb647a81..000000000 --- a/browser/components/safebrowsing/content/test/browser_whitelisted.js +++ /dev/null @@ -1,41 +0,0 @@ -/* Ensure that hostnames in the whitelisted pref are not blocked. */ - -const PREF_WHITELISTED_HOSTNAMES = "urlclassifier.skipHostnames"; -const TEST_PAGE = "http://www.itisatrap.org/firefox/its-an-attack.html"; -var tabbrowser = null; - -registerCleanupFunction(function() { - tabbrowser = null; - Services.prefs.clearUserPref(PREF_WHITELISTED_HOSTNAMES); - while (gBrowser.tabs.length > 1) { - gBrowser.removeCurrentTab(); - } -}); - -function testBlockedPage(window) { - info("Non-whitelisted pages must be blocked"); - ok(true, "about:blocked was shown"); -} - -function testWhitelistedPage(window) { - info("Whitelisted pages must be skipped"); - var getmeout_button = window.document.getElementById("getMeOutButton"); - var ignorewarning_button = window.document.getElementById("ignoreWarningButton"); - ok(!getmeout_button, "GetMeOut button not present"); - ok(!ignorewarning_button, "IgnoreWarning button not present"); -} - -add_task(function* testNormalBrowsing() { - tabbrowser = gBrowser; - let tab = tabbrowser.selectedTab = tabbrowser.addTab(); - - info("Load a test page that's whitelisted"); - Services.prefs.setCharPref(PREF_WHITELISTED_HOSTNAMES, "example.com,www.ItIsaTrap.org,example.net"); - yield promiseTabLoadEvent(tab, TEST_PAGE, "load"); - testWhitelistedPage(tab.ownerGlobal); - - info("Load a test page that's no longer whitelisted"); - Services.prefs.setCharPref(PREF_WHITELISTED_HOSTNAMES, ""); - yield promiseTabLoadEvent(tab, TEST_PAGE, "AboutBlockedLoaded"); - testBlockedPage(tab.ownerGlobal); -}); diff --git a/browser/components/safebrowsing/content/test/head.js b/browser/components/safebrowsing/content/test/head.js deleted file mode 100644 index 90eef0a3f..000000000 --- a/browser/components/safebrowsing/content/test/head.js +++ /dev/null @@ -1,55 +0,0 @@ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Task", - "resource://gre/modules/Task.jsm"); - -/** - * Waits for a load (or custom) event to finish in a given tab. If provided - * load an uri into the tab. - * - * @param tab - * The tab to load into. - * @param [optional] url - * The url to load, or the current url. - * @param [optional] event - * The load event type to wait for. Defaults to "load". - * @return {Promise} resolved when the event is handled. - * @resolves to the received event - * @rejects if a valid load event is not received within a meaningful interval - */ -function promiseTabLoadEvent(tab, url, eventType="load") -{ - info(`Wait tab event: ${eventType}`); - - function handle(loadedUrl) { - if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) { - info(`Skipping spurious load event for ${loadedUrl}`); - return false; - } - - info("Tab event received: load"); - return true; - } - - let loaded; - if (eventType === "load") { - loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle); - } else { - // No need to use handle. - loaded = - BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, eventType, - true, undefined, true); - } - - if (url) - BrowserTestUtils.loadURI(tab.linkedBrowser, url); - - return loaded; -} - -Services.prefs.setCharPref("urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple"); -Services.prefs.setCharPref("urlclassifier.phishTable", "test-phish-simple"); -Services.prefs.setCharPref("urlclassifier.blockedTable", "test-block-simple"); -SafeBrowsing.init(); |