Bug 1246244 - Allow non-CPOW documents to pass through saveImageURL properly. r=margaret,jaws
MozReview-Commit-ID: 1SbM2n3PNI1
--- a/toolkit/content/contentAreaUtils.js
+++ b/toolkit/content/contentAreaUtils.js
@@ -105,17 +105,17 @@ const nsISupportsCString = Components.in
* Offers to save an image URL to the file system.
*
* @param aURL (string)
* The URL of the image to be saved.
* @param aFileName (string)
* The suggested filename for the saved file.
* @param aFilePickerTitleKey (string, optional)
* Localized string key for an alternate title for the file
- * picker. If set to null
+ * picker. If set to null, this will default to something sensible.
* @param aShouldBypassCache (bool)
* If true, the image will always be retrieved from the server instead
* of the network or image caches.
* @param aSkipPrompt (bool)
* If true, we will attempt to save the file with the suggested
* filename to the default downloads folder without showing the
* file picker.
* @param aReferrer (nsIURI, optional)
@@ -133,33 +133,31 @@ const nsISupportsCString = Components.in
* Does not need to be provided is aDoc is passed.
*/
function saveImageURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache,
aSkipPrompt, aReferrer, aDoc, aContentType, aContentDisp,
aIsContentWindowPrivate)
{
forbidCPOW(aURL, "saveImageURL", "aURL");
forbidCPOW(aReferrer, "saveImageURL", "aReferrer");
- // Allow aSourceDocument to be a CPOW, but warn about it. Add-ons that are not
- // marked multi-process compatible can pass a document CPOW, but in-browser
- // consumers and multi-process compatible add-ons cannot when e10s is enabled.
- if (aDoc && Components.utils.isCrossProcessWrapper(aDoc)) {
- Deprecated.warning("saveImageURL should not be passed document CPOWs. " +
- "The caller should pass in the content type and " +
- "disposition themselves",
+
+ if (aDoc && aIsContentWindowPrivate == undefined) {
+ if (Components.utils.isCrossProcessWrapper(aDoc)) {
+ Deprecated.warning("saveImageURL should not be passed document CPOWs. " +
+ "The caller should pass in the content type and " +
+ "disposition themselves",
+ "https://bugzilla.mozilla.org/show_bug.cgi?id=1243643");
+ }
+ // This will definitely not work for in-browser code or multi-process compatible
+ // add-ons due to bug 1233497, which makes unsafe CPOW usage throw by default.
+ Deprecated.warning("saveImageURL should be passed the private state of " +
+ "the containing window.",
"https://bugzilla.mozilla.org/show_bug.cgi?id=1243643");
- if (aIsContentWindowPrivate == undefined) {
- // This will definitely not work for in-browser code or multi-process compatible
- // add-ons due to bug 1233497, which makes unsafe CPOW usage throw by default.
- Deprecated.warning("saveImageURL should be passed the private state of " +
- "the containing window.",
- "https://bugzilla.mozilla.org/show_bug.cgi?id=1243643");
- aIsContentWindowPrivate =
- PrivateBrowsingUtils.isContentWindowPrivate(aDoc.defaultView);
- }
+ aIsContentWindowPrivate =
+ PrivateBrowsingUtils.isContentWindowPrivate(aDoc.defaultView);
}
// We'd better have the private state by now.
if (aIsContentWindowPrivate == undefined) {
throw new Error("saveImageURL couldn't compute private state of content window");
}
if (!aShouldBypassCache && (aDoc && !Components.utils.isCrossProcessWrapper(aDoc)) &&