Backed out 3 changesets (bug 1406253)for build bustage in dom/base/nsCopySupport.cpp r=backout on a CLOSED TREE

Backed out changeset 284f3cc2880c (bug 1406253)
Backed out changeset aecb3d509a39 (bug 1406253)
Backed out changeset 9ce01198e8a1 (bug 1406253)
This commit is contained in:
Noemi Erli 2017-11-20 13:34:29 +02:00
parent 747b26c501
commit e90c67896c
15 changed files with 44 additions and 118 deletions

View File

@ -541,13 +541,13 @@ class ContextMenu {
let contentDisposition = null;
if (aEvent.target.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
aEvent.target instanceof Ci.nsIImageLoadingContent &&
aEvent.target.currentRequestFinalURI) {
aEvent.target.currentURI) {
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.target);
try {
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.getImgCacheForDocument(doc);
let props = imageCache.findEntryProperties(aEvent.target.currentRequestFinalURI, doc);
let props = imageCache.findEntryProperties(aEvent.target.currentURI, doc);
try {
contentType = props.get("type", Ci.nsISupportsCString).data;
@ -810,7 +810,7 @@ class ContextMenu {
// nsDocumentViewer::GetInImage. Make sure to update both if this is
// changed.
if (context.target instanceof Ci.nsIImageLoadingContent &&
context.target.currentRequestFinalURI) {
context.target.currentURI) {
context.onImage = true;
context.imageInfo = {
@ -832,7 +832,7 @@ class ContextMenu {
context.onCompletedImage = true;
}
context.mediaURL = context.target.currentRequestFinalURI.spec;
context.mediaURL = context.target.currentURI.spec;
const descURL = context.target.getAttribute("longdesc");

View File

@ -757,17 +757,6 @@ nsImageLoadingContent::GetCurrentURI(nsIURI** aURI)
return result.StealNSResult();
}
already_AddRefed<nsIURI>
nsImageLoadingContent::GetCurrentRequestFinalURI()
{
nsCOMPtr<nsIURI> uri;
if (mCurrentRequest) {
mCurrentRequest->GetFinalURI(getter_AddRefs(uri));
}
return uri.forget();
}
NS_IMETHODIMP
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
nsIStreamListener** aListener)

View File

@ -70,7 +70,6 @@ public:
int32_t
GetRequestType(imgIRequest* aRequest, mozilla::ErrorResult& aError);
already_AddRefed<nsIURI> GetCurrentURI(mozilla::ErrorResult& aError);
already_AddRefed<nsIURI> GetCurrentRequestFinalURI();
void ForceReload(const mozilla::dom::Optional<bool>& aNotify,
mozilla::ErrorResult& aError);

View File

@ -862,8 +862,8 @@ BrowserElementChild.prototype = {
documentURI: documentURI,
text: elem.textContent.substring(0, kLongestReturnedString)};
}
if (elem instanceof Ci.nsIImageLoadingContent && elem.currentRequestFinalURI) {
return {uri: elem.currentRequestFinalURI.spec, documentURI: documentURI};
if (elem instanceof Ci.nsIImageLoadingContent && elem.currentURI) {
return {uri: elem.currentURI.spec, documentURI: documentURI};
}
if (ChromeUtils.getClassName(elem) === "HTMLImageElement") {
return {uri: elem.src, documentURI: documentURI};

View File

@ -102,10 +102,6 @@ interface MozImageLoadingContent {
long getRequestType(imgIRequest aRequest);
[ChromeOnly,Throws]
readonly attribute URI? currentURI;
// Gets the final URI of the current request, if available.
// Otherwise, returns null.
[ChromeOnly]
readonly attribute URI? currentRequestFinalURI;
[ChromeOnly,Throws]
void forceReload(optional boolean aNotify);
[ChromeOnly]

View File

@ -88,7 +88,7 @@ interface imgIRequest : nsIRequest
/**
* The URI of the resource we ended up loading after all redirects, etc.
*/
readonly attribute nsIURI finalURI;
readonly attribute nsIURI currentURI;
readonly attribute imgINotificationObserver notificationObserver;

View File

@ -620,14 +620,14 @@ ShouldLoadCachedImage(imgRequest* aImgRequest,
* Cached images are keyed off of the first uri in a redirect chain.
* Hence content policies don't get a chance to test the intermediate hops
* or the final desitnation. Here we test the final destination using
* mFinalURI off of the imgRequest and passing it into content policies.
* mCurrentURI off of the imgRequest and passing it into content policies.
* For Mixed Content Blocker, we do an additional check to determine if any
* of the intermediary hops went through an insecure redirect with the
* mHadInsecureRedirect flag
*/
bool insecureRedirect = aImgRequest->HadInsecureRedirect();
nsCOMPtr<nsIURI> contentLocation;
aImgRequest->GetFinalURI(getter_AddRefs(contentLocation));
aImgRequest->GetCurrentURI(getter_AddRefs(contentLocation));
nsresult rv;
int16_t decision = nsIContentPolicy::REJECT_REQUEST;
@ -2985,12 +2985,12 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
nsCOMPtr<nsIURI> channelURI;
channel->GetURI(getter_AddRefs(channelURI));
nsCOMPtr<nsIURI> finalURI;
mRequest->GetFinalURI(getter_AddRefs(finalURI));
nsCOMPtr<nsIURI> currentURI;
mRequest->GetCurrentURI(getter_AddRefs(currentURI));
bool sameURI = false;
if (channelURI && finalURI) {
channelURI->Equals(finalURI, &sameURI);
if (channelURI && currentURI) {
channelURI->Equals(currentURI, &sameURI);
}
if (isFromCache && sameURI) {

View File

@ -89,7 +89,7 @@ imgRequest::~imgRequest()
nsresult
imgRequest::Init(nsIURI *aURI,
nsIURI *aFinalURI,
nsIURI *aCurrentURI,
bool aHadInsecureRedirect,
nsIRequest *aRequest,
nsIChannel *aChannel,
@ -105,7 +105,7 @@ imgRequest::Init(nsIURI *aURI,
MOZ_ASSERT(!mImage, "Multiple calls to init");
MOZ_ASSERT(aURI, "No uri");
MOZ_ASSERT(aFinalURI, "No final uri");
MOZ_ASSERT(aCurrentURI, "No current uri");
MOZ_ASSERT(aRequest, "No request");
MOZ_ASSERT(aChannel, "No channel");
@ -116,7 +116,7 @@ imgRequest::Init(nsIURI *aURI,
mURI = new ImageURL(aURI, rv);
NS_ENSURE_SUCCESS(rv, rv);
mFinalURI = aFinalURI;
mCurrentURI = aCurrentURI;
mRequest = aRequest;
mChannel = aChannel;
mTimedChannel = do_QueryInterface(mChannel);
@ -125,11 +125,11 @@ imgRequest::Init(nsIURI *aURI,
mCORSMode = aCORSMode;
mReferrerPolicy = aReferrerPolicy;
// If the original URI and the final URI are different, check whether the
// original URI is secure. We deliberately don't take the final URI into
// If the original URI and the current URI are different, check whether the
// original URI is secure. We deliberately don't take the current URI into
// account, as it needs to be handled using more complicated rules than
// earlier elements of the redirect chain.
if (aURI != aFinalURI) {
if (aURI != aCurrentURI) {
bool isHttps = false;
bool isChrome = false;
bool schemeLocal = false;
@ -437,14 +437,14 @@ nsresult imgRequest::GetURI(ImageURL** aURI)
}
nsresult
imgRequest::GetFinalURI(nsIURI** aURI)
imgRequest::GetCurrentURI(nsIURI** aURI)
{
MOZ_ASSERT(aURI);
LOG_FUNC(gImgLog, "imgRequest::GetFinalURI");
LOG_FUNC(gImgLog, "imgRequest::GetCurrentURI");
if (mFinalURI) {
*aURI = mFinalURI;
if (mCurrentURI) {
*aURI = mCurrentURI;
NS_ADDREF(*aURI);
return NS_OK;
}
@ -1322,8 +1322,8 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
if (LOG_TEST(LogLevel::Debug)) {
LOG_MSG_WITH_PARAM(gImgLog,
"imgRequest::OnChannelRedirect", "old",
mFinalURI ? mFinalURI->GetSpecOrDefault().get()
: "");
mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
: "");
}
// If the previous URI is a non-HTTPS URI, record that fact for later use by
@ -1332,9 +1332,9 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
bool isHttps = false;
bool isChrome = false;
bool schemeLocal = false;
if (NS_FAILED(mFinalURI->SchemeIs("https", &isHttps)) ||
NS_FAILED(mFinalURI->SchemeIs("chrome", &isChrome)) ||
NS_FAILED(NS_URIChainHasFlags(mFinalURI,
if (NS_FAILED(mCurrentURI->SchemeIs("https", &isHttps)) ||
NS_FAILED(mCurrentURI->SchemeIs("chrome", &isChrome)) ||
NS_FAILED(NS_URIChainHasFlags(mCurrentURI,
nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
&schemeLocal)) ||
(!isHttps && !isChrome && !schemeLocal)) {
@ -1352,20 +1352,20 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
}
}
// Update the final URI.
mChannel->GetURI(getter_AddRefs(mFinalURI));
// Update the current URI.
mChannel->GetURI(getter_AddRefs(mCurrentURI));
if (LOG_TEST(LogLevel::Debug)) {
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnChannelRedirect", "new",
mFinalURI ? mFinalURI->GetSpecOrDefault().get()
: "");
mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
: "");
}
// Make sure we have a protocol that returns data rather than opens an
// external application, e.g. 'mailto:'.
bool doesNotReturnData = false;
nsresult rv =
NS_URIChainHasFlags(mFinalURI,
NS_URIChainHasFlags(mCurrentURI,
nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
&doesNotReturnData);

View File

@ -66,7 +66,7 @@ public:
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
MOZ_MUST_USE nsresult Init(nsIURI* aURI,
nsIURI* aFinalURI,
nsIURI* aCurrentURI,
bool aHadInsecureRedirect,
nsIRequest* aRequest,
nsIChannel* aChannel,
@ -116,7 +116,7 @@ public:
bool GetMultipart() const;
// Returns whether we went through an insecure (non-HTTPS) redirect at some
// point during loading. This does not consider the final URI.
// point during loading. This does not consider the current URI.
bool HadInsecureRedirect() const;
// The CORS mode for which we loaded this image.
@ -152,7 +152,7 @@ public:
// OK to use on any thread.
nsresult GetURI(ImageURL** aURI);
nsresult GetFinalURI(nsIURI** aURI);
nsresult GetCurrentURI(nsIURI** aURI);
bool IsScheme(const char* aScheme) const;
bool IsChrome() const;
bool IsData() const;
@ -237,7 +237,7 @@ private:
// refcounting issues with nsStandardURL.
RefPtr<ImageURL> mURI;
// The URI of the resource we ended up loading after all redirects, etc.
nsCOMPtr<nsIURI> mFinalURI;
nsCOMPtr<nsIURI> mCurrentURI;
// The principal which triggered the load of this image. Generally either
// the principal of the document the image is being loaded into, or of the
// stylesheet which specified the image to load. Used when validating for CORS.

View File

@ -745,13 +745,13 @@ imgRequestProxy::GetURI(nsIURI** aURI)
}
nsresult
imgRequestProxy::GetFinalURI(nsIURI** aURI)
imgRequestProxy::GetCurrentURI(nsIURI** aURI)
{
if (!GetOwner()) {
return NS_ERROR_FAILURE;
}
return GetOwner()->GetFinalURI(aURI);
return GetOwner()->GetCurrentURI(aURI);
}
nsresult

View File

@ -848,6 +848,10 @@ var BrowserApp = {
selector: NativeWindow.contextmenus._disableRestricted("SHARE", NativeWindow.contextmenus.imageShareableContext),
order: NativeWindow.contextmenus.DEFAULT_HTML5_ORDER - 1, // Show above HTML5 menu items
showAsActions: function(aTarget) {
let doc = aTarget.ownerDocument;
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.getImgCacheForDocument(doc);
let props = imageCache.findEntryProperties(aTarget.currentURI, doc);
let src = aTarget.src;
return {
title: src,
@ -877,7 +881,7 @@ var BrowserApp = {
return;
}
ContentAreaUtils.saveImageURL(aTarget.currentRequestFinalURI.spec, null, "SaveImageTitle",
ContentAreaUtils.saveImageURL(aTarget.currentURI.spec, null, "SaveImageTitle",
false, true, aTarget.ownerDocument.documentURIObject,
aTarget.ownerDocument);
});

View File

@ -23,8 +23,6 @@ support-files =
image.jpg
image_page.html
silentAudioTrack.webm
doggy.png
firebird.png
[browser_audioCompeting.js]
tags = audiochannel
@ -64,7 +62,6 @@ skip-if = !e10s || !crashreporter
run-if = e10s && crashreporter
[browser_datetime_datepicker.js]
[browser_default_image_filename.js]
[browser_default_image_filename_redirect.js]
[browser_f7_caret_browsing.js]
[browser_findbar.js]
[browser_isSynthetic.js]

View File

@ -1,59 +0,0 @@
/**
* TestCase for bug 1406253
* <https://bugzilla.mozilla.org/show_bug.cgi?id=1406253>
*
* Load firebird.png, redirect it to doggy.png, and verify the filename is
* doggy.png in file picker dialog.
*/
let {WebRequest} = Cu.import("resource://gre/modules/WebRequest.jsm", {});
let MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init(window);
add_task(async function() {
const URL_FIREBIRD = "http://mochi.test:8888/browser/toolkit/content/tests/browser/firebird.png";
const URL_DOGGY = "http://mochi.test:8888/browser/toolkit/content/tests/browser/doggy.png";
function redirect(requestDetails) {
info("Redirecting: " + requestDetails.url);
return {
redirectUrl: URL_DOGGY
};
}
WebRequest.onBeforeRequest.addListener(redirect,
{urls: new MatchPatternSet(["http://*/*firebird.png"])},
["blocking"]
);
await BrowserTestUtils.withNewTab(URL_FIREBIRD,
async function(browser) {
// Click image to show context menu.
let popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown");
await BrowserTestUtils.synthesizeMouseAtCenter("img",
{ type: "contextmenu", button: 2 },
browser);
await popupShownPromise;
// Prepare mock file picker.
let showFilePickerPromise = new Promise(resolve => {
MockFilePicker.showCallback = fp => resolve(fp.defaultString);
});
registerCleanupFunction(function() {
MockFilePicker.cleanup();
});
// Select "Save Image As" option from context menu
var saveImageAsCommand = document.getElementById("context-saveimage");
saveImageAsCommand.doCommand();
let filename = await showFilePickerPromise;
is(filename, "doggy.png", "Verify image filename.");
// Close context menu.
let contextMenu = document.getElementById("contentAreaContextMenu");
let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
contextMenu.hidePopup();
await popupHiddenPromise;
});
WebRequest.onBeforeRequest.removeListener(redirect);
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB