Backed out changeset a28aa86d1ffe (bug 1354349)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 18 Apr 2017 08:51:03 +0200
changeset 353535 185945b7ea6394461cf4219212d9846c5a7f565a
parent 353534 0a15bd769093aea709311db221e11a62fb2983c0
child 353536 9c7ae09cb1cb8b6003e7d5a1246a3c6ad6004743
push id40945
push usercbook@mozilla.com
push dateTue, 18 Apr 2017 06:52:38 +0000
treeherderautoland@9c7ae09cb1cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1354349
milestone55.0a1
backs outa28aa86d1ffe2b60267607abe0e69847f2679c17
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset a28aa86d1ffe (bug 1354349)
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5030,20 +5030,37 @@ ContentParent::ForceTabPaint(TabParent* 
   ProcessHangMonitor::ForcePaint(mHangMonitorActor, aTabParent, aLayerObserverEpoch);
 }
 
 nsresult
 ContentParent::TransmitPermissionsFor(nsIChannel* aChannel)
 {
   MOZ_ASSERT(aChannel);
 #ifdef MOZ_PERMISSIONS
-
-  nsresult rv;
-  if (!aChannel->IsDocument()) {
-    return NS_OK;
+  // 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);
+
+  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
   // key for the document which will be created from this response.
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   if (NS_WARN_IF(!ssm)) {
     return NS_ERROR_FAILURE;
   }