Bug 1354349 - Use channel.isDocument in ContentParent::TransmitPermissionsFor r=mystor
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 20 Apr 2017 10:15:16 +0800
changeset 353999 8a42c7e1f799ea8c48aaa4166764ce681b9ad523
parent 353998 b01181410a8a8dcc757f39fad165d22e927ef3c0
child 354000 7ce95e24c0110c93ec1e4971922be456007bbc27
push id41132
push uservalentin.gosu@gmail.com
push dateThu, 20 Apr 2017 06:38:00 +0000
treeherderautoland@8a42c7e1f799 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1354349
milestone55.0a1
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
Bug 1354349 - Use channel.isDocument in ContentParent::TransmitPermissionsFor r=mystor MozReview-Commit-ID: L9b6UeXJ8o5
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5024,37 +5024,20 @@ ContentParent::ForceTabPaint(TabParent* 
   ProcessHangMonitor::ForcePaint(mHangMonitorActor, aTabParent, aLayerObserverEpoch);
 }
 
 nsresult
 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);
-
-  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;
-    }
+
+  nsresult rv;
+  if (!aChannel->IsDocument()) {
+    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;
   }