mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 514739: Remove 'block images from www.site.com' context menu item. r=gavin
This commit is contained in:
parent
388a7d4b88
commit
afe0644f0c
@ -152,10 +152,6 @@
|
||||
label="&setDesktopBackgroundCmd.label;"
|
||||
accesskey="&setDesktopBackgroundCmd.accesskey;"
|
||||
oncommand="gContextMenu.setDesktopBackground();"/>
|
||||
<menuitem id="context-blockimage"
|
||||
type="checkbox"
|
||||
accesskey="&blockImageCmd.accesskey;"
|
||||
oncommand="gContextMenu.toggleImageBlocking(this.getAttribute('checked') == 'true');"/>
|
||||
<menuitem id="context-viewimageinfo"
|
||||
label="&viewImageInfoCmd.label;"
|
||||
accesskey="&viewImageInfoCmd.accesskey;"
|
||||
|
@ -203,7 +203,7 @@ nsContextMenu.prototype = {
|
||||
onPlainTextLink = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var shouldShow = this.onSaveableLink || isMailtoInternal || onPlainTextLink;
|
||||
this.showItem("context-openlink", shouldShow);
|
||||
this.showItem("context-openlinkintab", shouldShow);
|
||||
@ -305,7 +305,7 @@ nsContextMenu.prototype = {
|
||||
|
||||
initMiscItems: function CM_initMiscItems() {
|
||||
var isTextSelected = this.isTextSelected;
|
||||
|
||||
|
||||
// Use "Bookmark This Link" if on a link.
|
||||
this.showItem("context-bookmarkpage",
|
||||
!(this.isContentSelected || this.onTextInput || this.onLink ||
|
||||
@ -331,36 +331,6 @@ nsContextMenu.prototype = {
|
||||
this.onTextInput && top.gBidiUI);
|
||||
this.showItem("context-bidi-page-direction-toggle",
|
||||
!this.onTextInput && top.gBidiUI);
|
||||
|
||||
var hostLabel = "";
|
||||
if (this.onImage) {
|
||||
var blockImage = document.getElementById("context-blockimage");
|
||||
|
||||
var uri = this.target
|
||||
.QueryInterface(Ci.nsIImageLoadingContent)
|
||||
.currentURI;
|
||||
|
||||
// this throws if the image URI doesn't have a host (eg, data: image URIs)
|
||||
// see bug 293758 for details
|
||||
try {
|
||||
hostLabel = uri.host;
|
||||
} catch (ex) { }
|
||||
|
||||
if (hostLabel) {
|
||||
if (hostLabel.length > 15)
|
||||
hostLabel = hostLabel.substr(0,15) + this.ellipsis;
|
||||
blockImage.label = gNavigatorBundle.getFormattedString("blockImages", [hostLabel]);
|
||||
|
||||
if (this.isImageBlocked())
|
||||
blockImage.setAttribute("checked", "true");
|
||||
else
|
||||
blockImage.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
|
||||
// Only show the block image item if the image can be blocked
|
||||
this.showItem("context-blockimage", this.onImage && hostLabel &&
|
||||
!gPrivateBrowsingUI.privateBrowsingEnabled);
|
||||
},
|
||||
|
||||
initSpellingItems: function() {
|
||||
@ -524,7 +494,7 @@ nsContextMenu.prototype = {
|
||||
if (this.target instanceof Ci.nsIImageLoadingContent &&
|
||||
this.target.currentURI) {
|
||||
this.onImage = true;
|
||||
|
||||
|
||||
var request =
|
||||
this.target.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
|
||||
if (request && (request.imageStatus & request.STATUS_SIZE_AVAILABLE))
|
||||
@ -597,7 +567,7 @@ nsContextMenu.prototype = {
|
||||
(elem instanceof HTMLAreaElement && elem.href) ||
|
||||
elem instanceof HTMLLinkElement ||
|
||||
elem.getAttributeNS("http://www.w3.org/1999/xlink", "type") == "simple")) {
|
||||
|
||||
|
||||
// Target is a link or a descendant of a link.
|
||||
this.onLink = true;
|
||||
|
||||
@ -616,7 +586,7 @@ nsContextMenu.prototype = {
|
||||
realLink = parent;
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
|
||||
// Remember corresponding element.
|
||||
this.link = realLink;
|
||||
this.linkURL = this.getLinkURL();
|
||||
@ -648,7 +618,7 @@ nsContextMenu.prototype = {
|
||||
|
||||
elem = elem.parentNode;
|
||||
}
|
||||
|
||||
|
||||
// See if the user clicked on MathML
|
||||
const NS_MathML = "http://www.w3.org/1998/Math/MathML";
|
||||
if ((this.target.nodeType == Node.TEXT_NODE &&
|
||||
@ -938,7 +908,7 @@ nsContextMenu.prototype = {
|
||||
saveLink: function() {
|
||||
// canonical def in nsURILoader.h
|
||||
const NS_ERROR_SAVE_LINK_AS_TIMEOUT = 0x805d0020;
|
||||
|
||||
|
||||
var doc = this.target.ownerDocument;
|
||||
urlSecurityCheck(this.linkURL, doc.nodePrincipal);
|
||||
var linkText = this.linkText();
|
||||
@ -970,10 +940,10 @@ nsContextMenu.prototype = {
|
||||
getService(Ci.nsIStringBundleService);
|
||||
const bundle = sbs.createBundle(
|
||||
"chrome://mozapps/locale/downloads/downloads.properties");
|
||||
|
||||
|
||||
const title = bundle.GetStringFromName("downloadErrorAlertTitle");
|
||||
const msg = bundle.GetStringFromName("downloadErrorGeneric");
|
||||
|
||||
|
||||
const promptSvc = Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Ci.nsIPromptService);
|
||||
promptSvc.alert(doc.defaultView, title, msg);
|
||||
@ -1001,7 +971,7 @@ nsContextMenu.prototype = {
|
||||
if (this.extListener)
|
||||
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
|
||||
},
|
||||
|
||||
|
||||
onDataAvailable: function saveLinkAs_onDataAvailable(aRequest, aContext,
|
||||
aInputStream,
|
||||
aOffset, aCount) {
|
||||
@ -1100,53 +1070,6 @@ nsContextMenu.prototype = {
|
||||
MailIntegration.sendMessage(this.mediaURL, "");
|
||||
},
|
||||
|
||||
toggleImageBlocking: function(aBlock) {
|
||||
var permissionmanager = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
|
||||
var uri = this.target.QueryInterface(Ci.nsIImageLoadingContent).currentURI;
|
||||
|
||||
if (aBlock)
|
||||
permissionmanager.add(uri, "image", Ci.nsIPermissionManager.DENY_ACTION);
|
||||
else
|
||||
permissionmanager.remove(uri.host, "image");
|
||||
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var app = brandBundle.getString("brandShortName");
|
||||
var message = gNavigatorBundle.getFormattedString(aBlock ?
|
||||
"imageBlockedWarning" : "imageAllowedWarning", [app, uri.host]);
|
||||
|
||||
var notificationBox = this.browser.getNotificationBox();
|
||||
var notification = notificationBox.getNotificationWithValue("images-blocked");
|
||||
|
||||
if (notification)
|
||||
notification.label = message;
|
||||
else {
|
||||
var self = this;
|
||||
var buttons = [{
|
||||
label: gNavigatorBundle.getString("undo"),
|
||||
accessKey: gNavigatorBundle.getString("undo.accessKey"),
|
||||
callback: function() { self.toggleImageBlocking(!aBlock); }
|
||||
}];
|
||||
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
|
||||
notificationBox.appendNotification(message, "images-blocked",
|
||||
"chrome://browser/skin/Info.png",
|
||||
priority, buttons);
|
||||
}
|
||||
|
||||
// Reload the page to show the effect instantly
|
||||
BrowserReload();
|
||||
},
|
||||
|
||||
isImageBlocked: function() {
|
||||
var permissionmanager = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
|
||||
var uri = this.target.QueryInterface(Ci.nsIImageLoadingContent).currentURI;
|
||||
|
||||
return permissionmanager.testPermission(uri, "image") == Ci.nsIPermissionManager.DENY_ACTION;
|
||||
},
|
||||
|
||||
// Generate email address and put it on clipboard.
|
||||
copyEmail: function() {
|
||||
// Copy the comma-separated list of email addresses only.
|
||||
@ -1248,7 +1171,7 @@ nsContextMenu.prototype = {
|
||||
|
||||
return makeURLAbsolute(this.link.baseURI, href);
|
||||
},
|
||||
|
||||
|
||||
getLinkURI: function() {
|
||||
try {
|
||||
return makeURI(this.linkURL);
|
||||
@ -1259,7 +1182,7 @@ nsContextMenu.prototype = {
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
getLinkProtocol: function() {
|
||||
if (this.linkURI)
|
||||
return this.linkURI.scheme; // can be |undefined|
|
||||
|
@ -225,7 +225,6 @@ function runTest(testNum) {
|
||||
"context-saveimage", true,
|
||||
"context-sendimage", true,
|
||||
"context-setDesktopBackground", true,
|
||||
"context-blockimage", true,
|
||||
"context-viewimageinfo", true]);
|
||||
closeContextMenu();
|
||||
openContextMenuFor(canvas); // Invoke context menu for next test.
|
||||
|
@ -49,7 +49,6 @@ _BROWSER_TEST_FILES = \
|
||||
browser_privatebrowsing_beforeunload.js \
|
||||
browser_privatebrowsing_certexceptionsui.js \
|
||||
browser_privatebrowsing_commandline_toggle.js \
|
||||
browser_privatebrowsing_contextmenu_blockimage.js \
|
||||
browser_privatebrowsing_cookieacceptdialog.js \
|
||||
browser_privatebrowsing_crh.js \
|
||||
browser_privatebrowsing_downloadmonitor.js \
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Private Browsing Tests.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ehsan Akhgari.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This test makes sure that private browsing mode disables the Block Image
|
||||
// context menu item.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const TEST_URI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/ctxmenu.html";
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function checkBlockImageMenuItem(expectedHidden, callback) {
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
executeSoon(function() {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let blockImage = document.getElementById("context-blockimage");
|
||||
let image = browser.contentDocument.getElementsByTagName("img")[0];
|
||||
ok(image, "The content image should be accessible");
|
||||
|
||||
contextMenu.addEventListener("popupshown", function() {
|
||||
contextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
is(blockImage.hidden, expectedHidden,
|
||||
"The Block Image menu item should " + (expectedHidden ? "" : "not ") + "be hidden");
|
||||
contextMenu.hidePopup();
|
||||
gBrowser.removeTab(tab);
|
||||
callback();
|
||||
}, false);
|
||||
|
||||
document.popupNode = image;
|
||||
EventUtils.synthesizeMouse(image, 2, 2,
|
||||
{type: "contextmenu", button: 2},
|
||||
browser.contentWindow);
|
||||
});
|
||||
}, true);
|
||||
browser.loadURI(TEST_URI);
|
||||
}
|
||||
|
||||
checkBlockImageMenuItem(false, function() {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
checkBlockImageMenuItem(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
checkBlockImageMenuItem(false, finish);
|
||||
});
|
||||
});
|
||||
}
|
@ -257,7 +257,7 @@
|
||||
Comment duplicated from browser-sets.inc:
|
||||
|
||||
Search Command Key Logic works like this:
|
||||
|
||||
|
||||
Unix: Ctrl+J (0.8, 0.9 support)
|
||||
Ctrl+K (cross platform binding)
|
||||
Mac: Ctrl+K (cross platform binding)
|
||||
@ -272,7 +272,7 @@
|
||||
for people to switch to Linux.
|
||||
|
||||
Do *not* tamper with these values without talking to ben@mozilla.org
|
||||
|
||||
|
||||
-->
|
||||
<!ENTITY searchFocus.commandkey "k">
|
||||
<!ENTITY searchFocus.commandkey2 "e">
|
||||
@ -361,7 +361,6 @@
|
||||
<!ENTITY copyVideoURLCmd.accesskey "o">
|
||||
<!ENTITY copyAudioURLCmd.label "Copy Audio Location">
|
||||
<!ENTITY copyAudioURLCmd.accesskey "o">
|
||||
<!ENTITY blockImageCmd.accesskey "B">
|
||||
<!ENTITY copyEmailCmd.label "Copy Email Address">
|
||||
<!ENTITY copyEmailCmd.accesskey "E">
|
||||
<!ENTITY thisFrameMenu.label "This Frame">
|
||||
|
@ -18,8 +18,6 @@ droponhomemsg=Do you want this document to be your new home page?
|
||||
contextMenuSearchText=Search %1$S for "%2$S"
|
||||
contextMenuSearchText.accesskey=S
|
||||
|
||||
blockImages=Block Images from %S
|
||||
|
||||
# bookmark dialog strings
|
||||
|
||||
bookmarkAllTabsDefault=[Folder Name]
|
||||
@ -80,11 +78,6 @@ popupWarningDontShowFromMessage=Don't show this message when pop-ups are blocked
|
||||
popupWarningDontShowFromStatusbar=Don't show info message when pop-ups are blocked
|
||||
popupShowPopupPrefix=Show '%S'
|
||||
|
||||
imageBlockedWarning=%S will now always block images from %S.
|
||||
imageAllowedWarning=%S will now allow images from %S.
|
||||
undo=Undo
|
||||
undo.accessKey=U
|
||||
|
||||
# missing plugin installer
|
||||
missingpluginsMessage.title=Additional plugins are required to display all the media on this page.
|
||||
missingpluginsMessage.button.label=Install Missing Plugins…
|
||||
|
@ -43,7 +43,6 @@ const gTimeout = 5000;
|
||||
|
||||
var websites = [
|
||||
"https://litmus.mozilla.org/testcase_files/firefox/5918/index.html",
|
||||
"http://www.google.com",
|
||||
"https://litmus.mozilla.org/testcase_files/firefox/cookies/cookie_single.html"
|
||||
];
|
||||
|
||||
@ -93,21 +92,11 @@ var testPermissionsDisabled = function()
|
||||
|
||||
controller.keypress(null, "VK_ESCAPE", {});
|
||||
|
||||
// There shouldn't be a block image entry in the context menu
|
||||
controller.open(websites[1]);
|
||||
controller.waitForPageLoad();
|
||||
|
||||
var image = new elementslib.ID(controller.tabs.activeTab, "logo");
|
||||
var blockImages = new elementslib.ID(controller.window.document, "context-blockimage");
|
||||
|
||||
controller.rightClick(image);
|
||||
controller.assertProperty(blockImages, "hidden", true);
|
||||
|
||||
// Enable the "Ask me every time" cookie behavior
|
||||
PrefsAPI.openPreferencesDialog(prefCookieHandler);
|
||||
|
||||
// No cookie dialog should show up
|
||||
controller.open(websites[2]);
|
||||
controller.open(websites[1]);
|
||||
controller.waitForPageLoad();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user