Bug 415846 - "can't report a page as not actually being a web forgery" (Restore the correct menu behaviour) [r=dcamp r=Pike r=gavin]
This commit is contained in:
@@ -38,13 +38,15 @@
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % reportphishDTD SYSTEM "chrome://browser/locale/safebrowsing/report-phishing.dtd">
|
||||
%reportphishDTD;
|
||||
<!ENTITY % safebrowsingDTD SYSTEM "chrome://browser/locale/safebrowsing/phishing-afterload-warning-message.dtd">
|
||||
%safebrowsingDTD;
|
||||
]>
|
||||
|
||||
<overlay id="reportPhishingMenuOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<broadcasterset id="mainBroadcasterSet">
|
||||
<broadcaster id="reportPhishingBroadcaster" disabled="true"/>
|
||||
<!--<broadcaster id="reportPhishingErrorBroadcaster" disabled="true"/>-->
|
||||
<broadcaster id="reportPhishingErrorBroadcaster" disabled="true"/>
|
||||
</broadcasterset>
|
||||
<menupopup id="menu_HelpPopup">
|
||||
<menuitem id="menu_HelpPopup_reportPhishingtoolmenu"
|
||||
@@ -54,13 +56,12 @@
|
||||
observes="reportPhishingBroadcaster"
|
||||
oncommand="openUILink(safebrowsing.getReportURL('Phish'), event);"
|
||||
onclick="checkForMiddleClick(this, event);"/>
|
||||
<!-- XXX Bug 415846
|
||||
<menuitem id="menu_HelpPopup_reportPhishingErrortoolmenu"
|
||||
label="&safeb.palm.notforgery.label2;"
|
||||
accesskey="&reportPhishSiteMenu.accesskey;"
|
||||
insertbefore="updateSeparator"
|
||||
observes="reportPhishingErrorBroadcaster"
|
||||
oncommand="openUILinkIn(safebrowsing.getReportURL('Error'), 'tab');"
|
||||
onclick="checkForMiddleClick(this, event);"/>-->
|
||||
onclick="checkForMiddleClick(this, event);"/>
|
||||
</menupopup>
|
||||
</overlay>
|
||||
|
||||
@@ -49,12 +49,29 @@ var safebrowsing = {
|
||||
},
|
||||
|
||||
setReportPhishingMenu: function() {
|
||||
|
||||
// A phishing page will have a specific about:blocked content documentURI
|
||||
var isPhishingPage = /^about:blocked\?e=phishingBlocked/.test(content.document.documentURI);
|
||||
|
||||
// Show/hide the appropriate menu item.
|
||||
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
|
||||
.hidden = isPhishingPage;
|
||||
document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
|
||||
.hidden = !isPhishingPage;
|
||||
|
||||
var broadcasterId = isPhishingPage
|
||||
? "reportPhishingErrorBroadcaster"
|
||||
: "reportPhishingBroadcaster";
|
||||
|
||||
var broadcaster = document.getElementById(broadcasterId);
|
||||
if (!broadcaster)
|
||||
return;
|
||||
|
||||
var uri = getBrowser().currentURI;
|
||||
var broadcaster = document.getElementById("reportPhishingBroadcaster");
|
||||
if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
|
||||
broadcaster.removeAttribute("disabled");
|
||||
else
|
||||
broadcaster.disabled = true;
|
||||
broadcaster.setAttribute("disabled", true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,14 @@ relativesrcdir = browser/components/safebrowsing/content/test
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# The browser chrome test for bug 415846 doesn't run on Mac because of its
|
||||
# bizarre special-and-unique snowflake of a help menu.
|
||||
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
_NON_MAC_BROWSER_TESTS = browser_bug415846.js
|
||||
endif
|
||||
|
||||
_BROWSER_FILES = browser_bug400731.js \
|
||||
$(_NON_MAC_BROWSER_TESTS) \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/* 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.*/
|
||||
var newBrowser;
|
||||
var menu;
|
||||
|
||||
function test() {
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
var newTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = newTab;
|
||||
newBrowser = gBrowser.getBrowserForTab(newTab);
|
||||
|
||||
// Navigate to a normal site
|
||||
gBrowser.addEventListener("load", testNormal, false);
|
||||
newBrowser.contentWindow.location = 'http://example.com/';
|
||||
}
|
||||
|
||||
function testNormal() {
|
||||
gBrowser.removeEventListener("load", testNormal, false);
|
||||
|
||||
// open the menu, to force it to update
|
||||
menu = document.getElementById("menu_HelpPopup");
|
||||
ok(menu, "Help menu should exist!");
|
||||
|
||||
menu.addEventListener("popupshown", testNormal_PopupListener, false);
|
||||
menu.openPopup(null, "", 0, 0, false, null);
|
||||
}
|
||||
|
||||
function testNormal_PopupListener() {
|
||||
menu.removeEventListener("popupshown", testNormal_PopupListener, false);
|
||||
|
||||
var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
|
||||
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
|
||||
is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites");
|
||||
is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites");
|
||||
menu.hidePopup();
|
||||
|
||||
// Now launch the phishing test. Can't use onload here because error pages don't
|
||||
// fire normal load events.
|
||||
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-a-trap.html';
|
||||
window.setTimeout(testPhishing, 2000);
|
||||
}
|
||||
|
||||
function testPhishing() {
|
||||
menu.addEventListener("popupshown", testPhishing_PopupListener, false);
|
||||
menu.openPopup(null, "", 0, 0, false, null);
|
||||
}
|
||||
|
||||
function testPhishing_PopupListener() {
|
||||
menu.removeEventListener("popupshown", testPhishing_PopupListener, false);
|
||||
|
||||
var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
|
||||
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
|
||||
is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites");
|
||||
is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites");
|
||||
menu.hidePopup();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
Reference in New Issue
Block a user