browser/components/safebrowsing/content/test/browser_bug415846.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:02dc23bf8ad7
1 /* Check for the correct behaviour of the report web forgery/not a web forgery
2 menu items.
3
4 Mac makes this astonishingly painful to test since their help menu is special magic,
5 but we can at least test it on the other platforms.*/
6 var menu;
7
8 function test() {
9 waitForExplicitFinish();
10
11 gBrowser.selectedTab = gBrowser.addTab();
12
13 // Navigate to a normal site
14 gBrowser.addEventListener("DOMContentLoaded", testNormal, false);
15 content.location = "http://example.com/";
16 }
17
18 function testNormal() {
19 gBrowser.removeEventListener("DOMContentLoaded", testNormal, false);
20
21 // open the menu, to force it to update
22 menu = document.getElementById("menu_HelpPopup");
23 ok(menu, "Help menu should exist!");
24
25 menu.addEventListener("popupshown", testNormal_PopupListener, false);
26 menu.openPopup(null, "", 0, 0, false, null);
27 }
28
29 function testNormal_PopupListener() {
30 menu.removeEventListener("popupshown", testNormal_PopupListener, false);
31
32 var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
33 var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
34 is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites");
35 is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites");
36 menu.hidePopup();
37
38 // Now launch the phishing test. Can't use onload here because error pages don't
39 // fire normal load events.
40 window.addEventListener("DOMContentLoaded", testPhishing, true);
41 content.location = "http://www.itisatrap.org/firefox/its-a-trap.html";
42 }
43
44 function testPhishing() {
45 window.removeEventListener("DOMContentLoaded", testPhishing, true);
46
47 menu.addEventListener("popupshown", testPhishing_PopupListener, false);
48 menu.openPopup(null, "", 0, 0, false, null);
49 }
50
51 function testPhishing_PopupListener() {
52 menu.removeEventListener("popupshown", testPhishing_PopupListener, false);
53
54 var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
55 var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
56 is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites");
57 is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites");
58 menu.hidePopup();
59
60 gBrowser.removeCurrentTab();
61 finish();
62 }

mercurial