michael@0: /* Check for the correct behaviour of the report web forgery/not a web forgery michael@0: menu items. michael@0: michael@0: Mac makes this astonishingly painful to test since their help menu is special magic, michael@0: but we can at least test it on the other platforms.*/ michael@0: var menu; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: michael@0: // Navigate to a normal site michael@0: gBrowser.addEventListener("DOMContentLoaded", testNormal, false); michael@0: content.location = "http://example.com/"; michael@0: } michael@0: michael@0: function testNormal() { michael@0: gBrowser.removeEventListener("DOMContentLoaded", testNormal, false); michael@0: michael@0: // open the menu, to force it to update michael@0: menu = document.getElementById("menu_HelpPopup"); michael@0: ok(menu, "Help menu should exist!"); michael@0: michael@0: menu.addEventListener("popupshown", testNormal_PopupListener, false); michael@0: menu.openPopup(null, "", 0, 0, false, null); michael@0: } michael@0: michael@0: function testNormal_PopupListener() { michael@0: menu.removeEventListener("popupshown", testNormal_PopupListener, false); michael@0: michael@0: var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu"); michael@0: var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu"); michael@0: is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites"); michael@0: is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites"); michael@0: menu.hidePopup(); michael@0: michael@0: // Now launch the phishing test. Can't use onload here because error pages don't michael@0: // fire normal load events. michael@0: window.addEventListener("DOMContentLoaded", testPhishing, true); michael@0: content.location = "http://www.itisatrap.org/firefox/its-a-trap.html"; michael@0: } michael@0: michael@0: function testPhishing() { michael@0: window.removeEventListener("DOMContentLoaded", testPhishing, true); michael@0: michael@0: menu.addEventListener("popupshown", testPhishing_PopupListener, false); michael@0: menu.openPopup(null, "", 0, 0, false, null); michael@0: } michael@0: michael@0: function testPhishing_PopupListener() { michael@0: menu.removeEventListener("popupshown", testPhishing_PopupListener, false); michael@0: michael@0: var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu"); michael@0: var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu"); michael@0: is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites"); michael@0: is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites"); michael@0: menu.hidePopup(); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }