Bug 1584204 Remove requestingLocation from nsContentPolicy.cpp r=ckerschb
☠☠ backed out by 10ce0c2900a1 ☠ ☠
authorSebastian Streich <sstreich@mozilla.com>
Mon, 30 Sep 2019 10:46:27 +0000
changeset 495646 bda8ceea80d0d53bfd79d5db5828c6a66dd2d221
parent 495645 6f8c20edadbacd0ce3978cd168883e6a33c39c3e
child 495647 10ce0c2900a19187e51f991ff89443cb07db0f78
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1584204
milestone71.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 1584204 Remove requestingLocation from nsContentPolicy.cpp r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D47255
dom/base/nsContentPolicy.cpp
--- a/dom/base/nsContentPolicy.cpp
+++ b/dom/base/nsContentPolicy.cpp
@@ -65,56 +65,41 @@ nsContentPolicy::~nsContentPolicy() {}
 
 inline nsresult nsContentPolicy::CheckPolicy(CPMethod policyMethod,
                                              nsIURI* contentLocation,
                                              nsILoadInfo* loadInfo,
                                              const nsACString& mimeType,
                                              int16_t* decision) {
   nsContentPolicyType contentType = loadInfo->InternalContentPolicyType();
   nsCOMPtr<nsISupports> requestingContext = loadInfo->GetLoadingContext();
-  nsCOMPtr<nsIURI> requestingLocation;
   nsCOMPtr<nsIPrincipal> loadingPrincipal = loadInfo->LoadingPrincipal();
-  if (loadingPrincipal) {
-    loadingPrincipal->GetURI(getter_AddRefs(requestingLocation));
-  }
-
   // sanity-check passed-through parameters
   MOZ_ASSERT(decision, "Null out pointer");
   WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI");
-  WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI");
 
 #ifdef DEBUG
   {
     nsCOMPtr<nsINode> node(do_QueryInterface(requestingContext));
     nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(requestingContext));
     nsCOMPtr<nsIBrowserChild> browserChild(
         do_QueryInterface(requestingContext));
     NS_ASSERTION(!requestingContext || node || window || browserChild,
                  "Context should be a DOM node, DOM window or a browserChild!");
   }
 #endif
 
-  /*
-   * There might not be a requestinglocation. This can happen for
-   * iframes with an image as src. Get the uri from the dom node.
-   * See bug 254510
-   */
   nsCOMPtr<mozilla::dom::Document> doc;
   nsCOMPtr<nsIContent> node = do_QueryInterface(requestingContext);
   if (node) {
     doc = node->OwnerDoc();
   }
   if (!doc) {
     doc = do_QueryInterface(requestingContext);
   }
 
-  if (!requestingLocation && doc) {
-    requestingLocation = doc->GetDocumentURI();
-  }
-
   nsContentPolicyType externalType =
       nsContentUtils::InternalContentPolicyTypeToExternal(contentType);
 
   /*
    * Enumerate mPolicies and ask each of them, taking the logical AND of
    * their permissions.
    */
   nsresult rv;
@@ -161,35 +146,29 @@ inline nsresult nsContentPolicy::CheckPo
   *decision = nsIContentPolicy::ACCEPT;
   return NS_OK;
 }
 
 // uses the parameters from ShouldXYZ to produce and log a message
 // logType must be a literal string constant
 #define LOG_CHECK(logType)                                                     \
   PR_BEGIN_MACRO                                                               \
-  nsCOMPtr<nsIURI> requestingLocation;                                         \
   nsCOMPtr<nsIPrincipal> loadingPrincipal = loadInfo->LoadingPrincipal();      \
-  if (loadingPrincipal) {                                                      \
-    loadingPrincipal->GetURI(getter_AddRefs(requestingLocation));              \
-  }                                                                            \
   /* skip all this nonsense if the call failed or logging is disabled */       \
   if (NS_SUCCEEDED(rv) && MOZ_LOG_TEST(gConPolLog, LogLevel::Debug)) {         \
     const char* resultName;                                                    \
     if (decision) {                                                            \
       resultName = NS_CP_ResponseName(*decision);                              \
     } else {                                                                   \
       resultName = "(null ptr)";                                               \
     }                                                                          \
     MOZ_LOG(                                                                   \
         gConPolLog, LogLevel::Debug,                                           \
         ("Content Policy: " logType ": <%s> <Ref:%s> result=%s",               \
          contentLocation ? contentLocation->GetSpecOrDefault().get() : "None", \
-         requestingLocation ? requestingLocation->GetSpecOrDefault().get()     \
-                            : "None",                                          \
          resultName));                                                         \
   }                                                                            \
   PR_END_MACRO
 
 NS_IMETHODIMP
 nsContentPolicy::ShouldLoad(nsIURI* contentLocation, nsILoadInfo* loadInfo,
                             const nsACString& mimeType, int16_t* decision) {
   // ShouldProcess does not need a content location, but we do