mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1246115 - Make gSafeBrowsing set the phishing menu item correctly. r=Gijs
Unfortunately, when onLocationChange is fired for an attack site for the about:blocked error page that we display, content.document has not been updated with the loaded error document, so content.document.documentURI will appear to be the previous page that had been loaded. In this patch, we update the parent's cache of documentURI in onStateChange as well, since this seems to be fired after the error page has been loaded. MozReview-Commit-ID: 1yLAw0JTEC6 --HG-- extra : rebase_source : 4f6f850fbe9c0b1f8ae3d6e2eaa42ef52a1e55c4
This commit is contained in:
parent
b1d8c6f915
commit
2a78d19d3c
@ -8,9 +8,14 @@
|
||||
var gSafeBrowsing = {
|
||||
|
||||
setReportPhishingMenu: function() {
|
||||
// A phishing page will have a specific about:blocked content documentURI
|
||||
var uri = gBrowser.currentURI;
|
||||
var isPhishingPage = uri && uri.spec.startsWith("about:blocked?e=phishingBlocked");
|
||||
// In order to detect whether or not we're at the phishing warning
|
||||
// page, we have to check the documentURI instead of the currentURI.
|
||||
// This is because when the DocShell loads an error page, the
|
||||
// currentURI stays at the original target, while the documentURI
|
||||
// will point to the internal error page we loaded instead.
|
||||
var docURI = gBrowser.selectedBrowser.documentURI;
|
||||
var isPhishingPage =
|
||||
docURI && docURI.spec.startsWith("about:blocked?e=phishingBlocked");
|
||||
|
||||
// Show/hide the appropriate menu item.
|
||||
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
|
||||
@ -26,6 +31,9 @@ var gSafeBrowsing = {
|
||||
if (!broadcaster)
|
||||
return;
|
||||
|
||||
// Now look at the currentURI to learn which page we were trying
|
||||
// to browse to.
|
||||
let uri = gBrowser.currentURI;
|
||||
if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
|
||||
broadcaster.removeAttribute("disabled");
|
||||
else
|
||||
|
@ -122,6 +122,14 @@ var WebProgressListener = {
|
||||
json.stateFlags = aStateFlags;
|
||||
json.status = aStatus;
|
||||
|
||||
// It's possible that this state change was triggered by
|
||||
// loading an internal error page, for which the parent
|
||||
// will want to know some details, so we'll update it with
|
||||
// the documentURI.
|
||||
if (aWebProgress && aWebProgress.isTopLevel) {
|
||||
json.documentURI = content.document.documentURIObject.spec;
|
||||
}
|
||||
|
||||
this._send("Content:StateChange", json, objects);
|
||||
},
|
||||
|
||||
|
@ -215,6 +215,9 @@ RemoteWebProgressManager.prototype = {
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "Content:StateChange":
|
||||
if (isTopLevel) {
|
||||
this._browser._documentURI = newURI(json.documentURI);
|
||||
}
|
||||
this._callProgressListeners("onStateChange", webProgress, request, json.stateFlags, json.status);
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user