From 1c4a8062420009e6f792befc3db60ad8ea99e2dc Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 18 Apr 2017 08:51:03 +0200 Subject: [PATCH] Backed out changeset a28aa86d1ffe (bug 1354349) --- dom/ipc/ContentParent.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 38e43058ecb3..4cdcb93dc20e 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -5035,10 +5035,27 @@ ContentParent::TransmitPermissionsFor(nsIChannel* aChannel) { MOZ_ASSERT(aChannel); #ifdef MOZ_PERMISSIONS + // Check if this channel is going to be used to create a document. If it has + // LOAD_DOCUMENT_URI set it is trivially creating a document. If + // LOAD_HTML_OBJECT_DATA is set it may or may not be used to create a + // document, depending on its MIME type. + nsLoadFlags loadFlags; + nsresult rv = aChannel->GetLoadFlags(&loadFlags); + NS_ENSURE_SUCCESS(rv, rv); - nsresult rv; - if (!aChannel->IsDocument()) { - return NS_OK; + if (!(loadFlags & nsIChannel::LOAD_DOCUMENT_URI)) { + if (loadFlags & nsIRequest::LOAD_HTML_OBJECT_DATA) { + nsAutoCString mimeType; + aChannel->GetContentType(mimeType); + if (nsContentUtils::HtmlObjectContentTypeForMIMEType(mimeType, nullptr) != + nsIObjectLoadingContent::TYPE_DOCUMENT) { + // The MIME type would not cause the creation of a document + return NS_OK; + } + } else { + // neither flag was set + return NS_OK; + } } // Get the principal for the channel result, so that we can get the permission