mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 789546 - Convert all JS users of imgICache service to use privacy-aware imgITools API instead. r=ehsan
This commit is contained in:
parent
df0cad19bc
commit
26c7f1fdc8
@ -820,7 +820,7 @@ nsContextMenu.prototype = {
|
||||
canvas.height = video.videoHeight;
|
||||
var ctxDraw = canvas.getContext("2d");
|
||||
ctxDraw.drawImage(video, 0, 0);
|
||||
saveImageURL(canvas.toDataURL("image/jpeg", ""), name, "SaveImageTitle", true, false, document.documentURIObject);
|
||||
saveImageURL(canvas.toDataURL("image/jpeg", ""), name, "SaveImageTitle", true, false, document.documentURIObject, this.target.ownerDocument);
|
||||
},
|
||||
|
||||
fullScreenVideo: function () {
|
||||
@ -1061,12 +1061,12 @@ nsContextMenu.prototype = {
|
||||
if (this.onCanvas) {
|
||||
// Bypass cache, since it's a data: URL.
|
||||
saveImageURL(this.target.toDataURL(), "canvas.png", "SaveImageTitle",
|
||||
true, false, doc.documentURIObject);
|
||||
true, false, doc.documentURIObject, doc);
|
||||
}
|
||||
else if (this.onImage) {
|
||||
urlSecurityCheck(this.mediaURL, doc.nodePrincipal);
|
||||
saveImageURL(this.mediaURL, null, "SaveImageTitle", false,
|
||||
false, doc.documentURIObject);
|
||||
false, doc.documentURIObject, doc);
|
||||
}
|
||||
else if (this.onVideo || this.onAudio) {
|
||||
urlSecurityCheck(this.mediaURL, doc.nodePrincipal);
|
||||
|
@ -85,8 +85,8 @@ Sanitizer.prototype = {
|
||||
cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
||||
} catch(er) {}
|
||||
|
||||
var imageCache = Cc["@mozilla.org/image/cache;1"].
|
||||
getService(Ci.imgICache);
|
||||
var imageCache = Cc["@mozilla.org/image/tools;1"].
|
||||
getService(Ci.imgITools).getImgCacheForDocument(null);
|
||||
try {
|
||||
imageCache.clearCache(false); // true=chrome, false=content
|
||||
} catch(er) {}
|
||||
|
@ -651,8 +651,8 @@ PrivateBrowsingService.prototype = {
|
||||
}
|
||||
|
||||
// Image Cache
|
||||
let (imageCache = Cc["@mozilla.org/image/cache;1"].
|
||||
getService(Ci.imgICache)) {
|
||||
let (imageCache = Cc["@mozilla.org/image/tools;1"].
|
||||
getService(Ci.imgITools).getImgCacheForDocument(null)) {
|
||||
try {
|
||||
imageCache.clearCache(false); // true=chrome, false=content
|
||||
} catch (ex) {
|
||||
|
@ -450,8 +450,10 @@ var BrowserApp = {
|
||||
NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.shareImage"),
|
||||
NativeWindow.contextmenus.imageSaveableContext,
|
||||
function(aTarget) {
|
||||
let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache);
|
||||
let props = imageCache.findEntryProperties(aTarget.currentURI, aTarget.ownerDocument.characterSet);
|
||||
let doc = aTarget.ownerDocument;
|
||||
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
|
||||
.getImgCacheForDocument(doc);
|
||||
let props = imageCache.findEntryProperties(aTarget.currentURI, doc.characterSet);
|
||||
let src = aTarget.src;
|
||||
let type = "";
|
||||
try {
|
||||
@ -471,8 +473,10 @@ var BrowserApp = {
|
||||
NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.saveImage"),
|
||||
NativeWindow.contextmenus.imageSaveableContext,
|
||||
function(aTarget) {
|
||||
let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache);
|
||||
let props = imageCache.findEntryProperties(aTarget.currentURI, aTarget.ownerDocument.characterSet);
|
||||
let doc = aTarget.ownerDocument;
|
||||
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
|
||||
.getImgCacheForDocument(doc);
|
||||
let props = imageCache.findEntryProperties(aTarget.currentURI, doc.characterSet);
|
||||
let contentDisposition = "";
|
||||
let type = "";
|
||||
try {
|
||||
|
@ -63,7 +63,8 @@ Sanitizer.prototype = {
|
||||
cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
||||
} catch(er) {}
|
||||
|
||||
let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache);
|
||||
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
|
||||
.getImgCacheForDocument(null);
|
||||
try {
|
||||
imageCache.clearCache(false); // true=chrome, false=content
|
||||
} catch(er) {}
|
||||
|
@ -105,14 +105,15 @@ const imgICache = Components.interfaces.imgICache;
|
||||
const nsISupportsCString = Components.interfaces.nsISupportsCString;
|
||||
|
||||
function saveImageURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache,
|
||||
aSkipPrompt, aReferrer)
|
||||
aSkipPrompt, aReferrer, aDoc)
|
||||
{
|
||||
var contentType = null;
|
||||
var contentDisposition = null;
|
||||
if (!aShouldBypassCache) {
|
||||
try {
|
||||
var imageCache = Components.classes["@mozilla.org/image/cache;1"]
|
||||
.getService(imgICache);
|
||||
var imageCache = Components.classes["@mozilla.org/image/tools;1"]
|
||||
.getService(Components.interfaces.imgITools)
|
||||
.getImgCacheForDocument(aDoc);
|
||||
var props =
|
||||
imageCache.findEntryProperties(makeURI(aURL, getCharsetforSave(null)));
|
||||
if (props) {
|
||||
|
@ -27,6 +27,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_browserDrop.js \
|
||||
browser_Services.js \
|
||||
browser_DeferredTask.js \
|
||||
browser_default_image_filename.js \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,55 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init();
|
||||
|
||||
/**
|
||||
* TestCase for bug 564387
|
||||
* <https://bugzilla.mozilla.org/show_bug.cgi?id=564387>
|
||||
*/
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
var fileName;
|
||||
|
||||
gBrowser.loadURI("data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7");
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
gBrowser.addTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
gBrowser.addEventListener("pageshow", function pageShown(event) {
|
||||
if (event.target.location == "about:blank")
|
||||
return;
|
||||
gBrowser.removeEventListener("pageshow", pageShown);
|
||||
|
||||
executeSoon(function () {
|
||||
document.addEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
var img = gBrowser.contentDocument.getElementsByClassName("decoded")[0];
|
||||
EventUtils.synthesizeMouseAtCenter(img,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
gBrowser.contentWindow);
|
||||
});
|
||||
});
|
||||
|
||||
function contextMenuOpened(event) {
|
||||
event.currentTarget.removeEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
MockFilePicker.showCallback = function(fp) {
|
||||
is(fp.defaultString, "index.gif");
|
||||
executeSoon(finish);
|
||||
};
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
MockFilePicker.cleanup();
|
||||
});
|
||||
|
||||
// Select "Save Image As" option from context menu
|
||||
var saveImageAsCommand = document.getElementById("context-saveimage");
|
||||
saveImageAsCommand.doCommand();
|
||||
|
||||
event.target.hidePopup();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user