1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/safebrowsing/content/test/browser_bug415846.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* Check for the correct behaviour of the report web forgery/not a web forgery 1.5 +menu items. 1.6 + 1.7 +Mac makes this astonishingly painful to test since their help menu is special magic, 1.8 +but we can at least test it on the other platforms.*/ 1.9 +var menu; 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + gBrowser.selectedTab = gBrowser.addTab(); 1.15 + 1.16 + // Navigate to a normal site 1.17 + gBrowser.addEventListener("DOMContentLoaded", testNormal, false); 1.18 + content.location = "http://example.com/"; 1.19 +} 1.20 + 1.21 +function testNormal() { 1.22 + gBrowser.removeEventListener("DOMContentLoaded", testNormal, false); 1.23 + 1.24 + // open the menu, to force it to update 1.25 + menu = document.getElementById("menu_HelpPopup"); 1.26 + ok(menu, "Help menu should exist!"); 1.27 + 1.28 + menu.addEventListener("popupshown", testNormal_PopupListener, false); 1.29 + menu.openPopup(null, "", 0, 0, false, null); 1.30 +} 1.31 + 1.32 +function testNormal_PopupListener() { 1.33 + menu.removeEventListener("popupshown", testNormal_PopupListener, false); 1.34 + 1.35 + var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu"); 1.36 + var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu"); 1.37 + is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites"); 1.38 + is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites"); 1.39 + menu.hidePopup(); 1.40 + 1.41 + // Now launch the phishing test. Can't use onload here because error pages don't 1.42 + // fire normal load events. 1.43 + window.addEventListener("DOMContentLoaded", testPhishing, true); 1.44 + content.location = "http://www.itisatrap.org/firefox/its-a-trap.html"; 1.45 +} 1.46 + 1.47 +function testPhishing() { 1.48 + window.removeEventListener("DOMContentLoaded", testPhishing, true); 1.49 + 1.50 + menu.addEventListener("popupshown", testPhishing_PopupListener, false); 1.51 + menu.openPopup(null, "", 0, 0, false, null); 1.52 +} 1.53 + 1.54 +function testPhishing_PopupListener() { 1.55 + menu.removeEventListener("popupshown", testPhishing_PopupListener, false); 1.56 + 1.57 + var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu"); 1.58 + var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu"); 1.59 + is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites"); 1.60 + is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites"); 1.61 + menu.hidePopup(); 1.62 + 1.63 + gBrowser.removeCurrentTab(); 1.64 + finish(); 1.65 +}