Bug 1407498 - Don't query loadingprincipal in common case. r=baku
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 11 Oct 2017 17:07:35 +0800
changeset 387818 bad2101d54e48e8718d7e8cefd61bfea6971d41a
parent 387817 970cab99ef60d868f592e94b5cebe18d2f67efd8
child 387819 a29c27afe9714839c54cc9a8fee1e5cbb8b188b1
push id32735
push userarchaeopteryx@coole-files.de
push dateTue, 24 Oct 2017 09:53:08 +0000
treeherdermozilla-central@a80d568a417e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1407498
milestone58.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 1407498 - Don't query loadingprincipal in common case. r=baku We queried 'loadingprincipal' attribute on the common call path, however this should be queried if it's loaded by System Principal. Also rename loadingprincipal to triggeringprincipal
browser/base/content/pageinfo/pageInfo.js
browser/base/content/tabbrowser.xml
browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsGkAtomList.h
dom/base/nsImageLoadingContent.cpp
dom/html/HTMLMediaElement.cpp
dom/media/ChannelMediaResource.cpp
layout/xul/nsImageBoxFrame.cpp
toolkit/content/widgets/menu.xml
widget/cocoa/nsMenuItemIconX.h
widget/cocoa/nsMenuItemIconX.mm
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -846,17 +846,17 @@ function makePreview(row) {
 
     var newImage = new Image;
     newImage.id = "thepreviewimage";
     var physWidth = 0, physHeight = 0;
     var width = 0, height = 0;
 
     let serial = Components.classes["@mozilla.org/network/serialization-helper;1"]
                            .getService(Components.interfaces.nsISerializationHelper);
-    let loadingPrincipalStr = serial.serializeToString(gDocInfo.principal);
+    let triggeringPrinStr = serial.serializeToString(gDocInfo.principal);
     if ((item.HTMLLinkElement || item.HTMLInputElement ||
          item.HTMLImageElement || item.SVGImageElement ||
          (item.HTMLObjectElement && mimeType && mimeType.startsWith("image/")) ||
          isBG) && isProtocolAllowed) {
       // We need to wait for the image to finish loading before using width & height
       newImage.addEventListener("loadend", function() {
         physWidth = newImage.width || 0;
         physHeight = newImage.height || 0;
@@ -905,35 +905,35 @@ function makePreview(row) {
             imageSize = gBundle.getFormattedString("mediaDimensions",
                                                    [formatNumber(width),
                                                     formatNumber(height)]);
           }
         }
         setItemValue("imagedimensiontext", imageSize);
       }, {once: true});
 
-      newImage.setAttribute("loadingprincipal", loadingPrincipalStr);
+      newImage.setAttribute("triggeringprincipal", triggeringPrinStr);
       newImage.setAttribute("src", url);
     } else {
       // Handle the case where newImage is not used for width & height
       if (item.HTMLVideoElement && isProtocolAllowed) {
         newImage = document.createElementNS("http://www.w3.org/1999/xhtml", "video");
         newImage.id = "thepreviewimage";
-        newImage.setAttribute("loadingprincipal", loadingPrincipalStr);
+        newImage.setAttribute("triggeringprincipal", triggeringPrinStr);
         newImage.src = url;
         newImage.controls = true;
         width = physWidth = item.videoWidth;
         height = physHeight = item.videoHeight;
 
         document.getElementById("theimagecontainer").collapsed = false;
         document.getElementById("brokenimagecontainer").collapsed = true;
       } else if (item.HTMLAudioElement && isProtocolAllowed) {
         newImage = new Audio;
         newImage.id = "thepreviewimage";
-        newImage.setAttribute("loadingprincipal", loadingPrincipalStr);
+        newImage.setAttribute("triggeringprincipal", triggeringPrinStr);
         newImage.src = url;
         newImage.controls = true;
         isAudio = true;
 
         document.getElementById("theimagecontainer").collapsed = false;
         document.getElementById("brokenimagecontainer").collapsed = true;
       } else {
         // fallback image for protocols not allowed (e.g., javascript:)
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -7747,17 +7747,17 @@
                   anonid="tab-loading-burst"
                   class="tab-loading-burst"/>
         <xul:hbox xbl:inherits="pinned,selected=visuallyselected,titlechanged,attention"
                   class="tab-content" align="center">
           <xul:hbox xbl:inherits="fadein,pinned,busy,progress,selected=visuallyselected"
                     anonid="tab-throbber"
                     class="tab-throbber"
                     layer="true"/>
-          <xul:image xbl:inherits="src=image,loadingprincipal=iconloadingprincipal,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
+          <xul:image xbl:inherits="src=image,triggeringprincipal=iconloadingprincipal,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
                      anonid="tab-icon-image"
                      class="tab-icon-image"
                      validate="never"
                      role="presentation"/>
           <xul:image xbl:inherits="sharing,selected=visuallyselected,pinned"
                      anonid="sharing-icon"
                      class="tab-sharing-icon-overlay"
                      role="presentation"/>
--- a/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
@@ -24,17 +24,17 @@ function testFirstPartyDomain(pageInfo) 
         tree.treeBoxObject.ensureRowIsVisible(i);
         tree.focus();
 
         let preview = pageInfo.document.getElementById("thepreviewimage");
         info("preview.src=" + preview.src);
 
         // For <img>, we will query imgIRequest.imagePrincipal later, so we wait
         // for loadend event. For <audio> and <video>, so far we only can get
-        // the loadingprincipal attribute on the node, so we simply wait for
+        // the triggeringprincipal attribute on the node, so we simply wait for
         // loadstart.
         if (i == 0) {
           await waitForEvent(preview, "loadend");
         } else {
           await waitForEvent(preview, "loadstart");
         }
 
         info("preview load " + i);
@@ -43,20 +43,20 @@ function testFirstPartyDomain(pageInfo) 
         // it won't have origin attributes, now we've changed to loadingPrincipal
         // to the content in bug 1376971, it should have firstPartyDomain set.
         if (i == 0) {
           let req = preview.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
           Assert.equal(req.imagePrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN,
                        "imagePrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN);
         }
 
-        // Check the node has the attribute 'loadingprincipal'.
+        // Check the node has the attribute 'triggeringprincipal'.
         let serial = Components.classes["@mozilla.org/network/serialization-helper;1"]
                                .getService(Components.interfaces.nsISerializationHelper);
-        let loadingPrincipalStr = preview.getAttribute("loadingprincipal");
+        let loadingPrincipalStr = preview.getAttribute("triggeringprincipal");
         let loadingPrincipal = serial.deserializeObject(loadingPrincipalStr);
         Assert.equal(loadingPrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN,
                      "loadingPrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN);
 
       }
 
       resolve();
     });
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -10475,69 +10475,69 @@ nsContentUtils::AppendNativeAnonymousChi
   // Detect and handle this case.
   if (!(aFlags & nsIContent::eSkipDocumentLevelNativeAnonymousContent) &&
       aContent == aContent->OwnerDoc()->GetRootElement()) {
     AppendDocumentLevelNativeAnonymousContentTo(aContent->OwnerDoc(), aKids);
   }
 }
 
 /* static */ bool
-nsContentUtils::GetLoadingPrincipalForXULNode(nsIContent* aLoadingNode,
-                                              nsIPrincipal* aDefaultPrincipal,
-                                              nsIPrincipal** aLoadingPrincipal)
+nsContentUtils::QueryTriggeringPrincipal(nsIContent* aLoadingNode,
+                                         nsIPrincipal* aDefaultPrincipal,
+                                         nsIPrincipal** aTriggeringPrincipal)
 {
   MOZ_ASSERT(aLoadingNode);
-  MOZ_ASSERT(aLoadingPrincipal);
+  MOZ_ASSERT(aTriggeringPrincipal);
 
   bool result = false;
   nsCOMPtr<nsIPrincipal> loadingPrincipal = aDefaultPrincipal;
   if (!loadingPrincipal) {
     loadingPrincipal = aLoadingNode->NodePrincipal();
   }
+
+  // If aLoadingNode is content, bail out early.
+  if (!aLoadingNode->NodePrincipal()->GetIsSystemPrincipal()) {
+    loadingPrincipal.forget(aTriggeringPrincipal);
+    return result;
+  }
+
   nsAutoString loadingStr;
-  aLoadingNode->GetAttr(kNameSpaceID_None, nsGkAtoms::loadingprincipal,
+  aLoadingNode->GetAttr(kNameSpaceID_None, nsGkAtoms::triggeringprincipal,
                         loadingStr);
 
-  // Fall back to mContent's principal if 'loadingprincipal' isn't specified,
-  // or if the doc isn't loaded by System Principal.
-  if (loadingStr.IsEmpty() ||
-      !aLoadingNode->OwnerDoc()->NodePrincipal()->GetIsSystemPrincipal()) {
-    loadingPrincipal.forget(aLoadingPrincipal);
+  // Fall back if 'triggeringprincipal' isn't specified,
+  if (loadingStr.IsEmpty()) {
+    loadingPrincipal.forget(aTriggeringPrincipal);
     return result;
   }
 
   nsCOMPtr<nsISupports> serializedPrincipal;
   NS_DeserializeObject(NS_ConvertUTF16toUTF8(loadingStr),
                        getter_AddRefs(serializedPrincipal));
-  loadingPrincipal = do_QueryInterface(serializedPrincipal);
-  if (loadingPrincipal) {
-    // We only allow specifying loadingprincipal attribute on a node loaded by
-    // SystemPrincipal.
-    MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(aLoadingNode->NodePrincipal()),
-               "aLoadingNode Should be loaded with SystemPrincipal");
-
+  nsCOMPtr<nsIPrincipal> serializedPrin = do_QueryInterface(serializedPrincipal);
+  if (serializedPrin) {
     result = true;
+    serializedPrin.forget(aTriggeringPrincipal);
   } else {
     // Fallback if the deserialization is failed.
-    loadingPrincipal = aLoadingNode->NodePrincipal();
-  }
-
-  loadingPrincipal.forget(aLoadingPrincipal);
+    loadingPrincipal.forget(aTriggeringPrincipal);
+  }
+
   return result;
 }
 
 /* static */ void
 nsContentUtils::GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode,
-                                                      nsIPrincipal** aLoadingPrincipal,
+                                                      nsIPrincipal** aTriggeringPrincipal,
                                                       nsContentPolicyType& aContentPolicyType,
                                                       uint64_t* aRequestContextID)
 {
   MOZ_ASSERT(aRequestContextID);
 
-  bool result = GetLoadingPrincipalForXULNode(aLoadingNode, aLoadingPrincipal);
+  bool result = QueryTriggeringPrincipal(aLoadingNode, aTriggeringPrincipal);
   if (result) {
     // Set the content policy type to TYPE_INTERNAL_IMAGE_FAVICON for
     // indicating it's a favicon loading.
     aContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON;
 
     nsAutoString requestContextID;
     aLoadingNode->GetAttr(kNameSpaceID_None, nsGkAtoms::requestcontextid,
                           requestContextID);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -3078,44 +3078,45 @@ public:
    *
    * See `AllChildrenIterator` for the description of the `aFlags` parameter.
    */
   static void AppendNativeAnonymousChildren(const nsIContent* aContent,
                                             nsTArray<nsIContent*>& aKids,
                                             uint32_t aFlags);
 
   /**
-   * Query loadingPrincipal if it is specified as 'loadingprincipal' attribute on
-   * aLoadingNode, otherwise the NodePrincipal of aLoadingNode is returned
-   * (which is System Principal).
+   * Query triggeringPrincipal if there's a 'triggeringprincipal' attribute on
+   * aLoadingNode, if no such attribute is specified, aDefaultPrincipal is
+   * returned if it is provided, otherwise the NodePrincipal of aLoadingNode is
+   * returned.
    *
-   * Return true if aLoadingPrincipal has 'loadingprincipal' attributes, and
-   * the value 'loadingprincipal' is also successfully deserialized, otherwise
+   * Return true if aLoadingNode has a 'triggeringprincipal' attribute, and
+   * the value 'triggeringprincipal' is also successfully deserialized, otherwise
    * return false.
    */
   static bool
-  GetLoadingPrincipalForXULNode(nsIContent* aLoadingNode,
-                                nsIPrincipal* aDefaultPrincipal,
-                                nsIPrincipal** aTriggeringPrincipal);
+  QueryTriggeringPrincipal(nsIContent* aLoadingNode,
+                           nsIPrincipal* aDefaultPrincipal,
+                           nsIPrincipal** aTriggeringPrincipal);
 
   static bool
-  GetLoadingPrincipalForXULNode(nsIContent* aLoadingNode,
-                                nsIPrincipal** aTriggeringPrincipal)
+  QueryTriggeringPrincipal(nsIContent* aLoadingNode,
+                           nsIPrincipal** aTriggeringPrincipal)
   {
-    return GetLoadingPrincipalForXULNode(aLoadingNode, nullptr, aTriggeringPrincipal);
+    return QueryTriggeringPrincipal(aLoadingNode, nullptr, aTriggeringPrincipal);
   }
 
   /**
    * Returns the content policy type that should be used for loading images
    * for displaying in the UI.  The sources of such images can be <xul:image>,
    * <xul:menuitem> on OSX where we load the image through nsMenuItemIconX, etc.
    */
   static void
   GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode,
-                                        nsIPrincipal** aLoadingPrincipal,
+                                        nsIPrincipal** aTriggeringPrincipal,
                                         nsContentPolicyType& aContentPolicyType,
                                         uint64_t* aRequestContextID);
 
   static nsresult
   CreateJSValueFromSequenceOfObject(JSContext* aCx,
                                     const mozilla::dom::Sequence<JSObject*>& aTransfer,
                                     JS::MutableHandle<JS::Value> aValue);
 
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -639,17 +639,17 @@ GK_ATOM(listcol, "listcol")
 GK_ATOM(listcols, "listcols")
 GK_ATOM(listener, "listener")
 GK_ATOM(listhead, "listhead")
 GK_ATOM(listheader, "listheader")
 GK_ATOM(listing, "listing")
 GK_ATOM(listitem, "listitem")
 GK_ATOM(listrows, "listrows")
 GK_ATOM(load, "load")
-GK_ATOM(loadingprincipal, "loadingprincipal")
+GK_ATOM(triggeringprincipal, "triggeringprincipal")
 GK_ATOM(localedir, "localedir")
 GK_ATOM(localName, "local-name")
 GK_ATOM(longdesc, "longdesc")
 GK_ATOM(loop, "loop")
 GK_ATOM(low, "low")
 GK_ATOM(lowerAlpha, "lower-alpha")
 GK_ATOM(lowerFirst, "lower-first")
 GK_ATOM(lowerRoman, "lower-roman")
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -1039,20 +1039,20 @@ nsImageLoadingContent::LoadImage(nsIURI*
   }
 
   RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
   nsCOMPtr<nsIContent> content =
       do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
 
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   bool result =
-    nsContentUtils::GetLoadingPrincipalForXULNode(content, aTriggeringPrincipal,
-                                                  getter_AddRefs(triggeringPrincipal));
+    nsContentUtils::QueryTriggeringPrincipal(content, aTriggeringPrincipal,
+                                             getter_AddRefs(triggeringPrincipal));
 
-  // If result is true, which means this node has specified 'loadingprincipal'
+  // If result is true, which means this node has specified 'triggeringprincipal'
   // attribute on it, so we use favicon as the policy type.
   nsContentPolicyType policyType = result ?
                                      nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON:
                                      PolicyTypeForLoad(aImageLoadType);
 
   nsCOMPtr<nsINode> thisNode =
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   nsresult rv = nsContentUtils::LoadImage(aNewURI,
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1188,26 +1188,27 @@ public:
       securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
     }
 
     MOZ_ASSERT(aElement->IsAnyOfHTMLElements(nsGkAtoms::audio, nsGkAtoms::video));
     nsContentPolicyType contentPolicyType = aElement->IsHTMLElement(nsGkAtoms::audio)
       ? nsIContentPolicy::TYPE_INTERNAL_AUDIO :
         nsIContentPolicy::TYPE_INTERNAL_VIDEO;
 
-    // If aElement has 'loadingprincipal' attribute, we will use the value as
+    // If aElement has 'triggeringprincipal' attribute, we will use the value as
     // triggeringPrincipal for the channel, otherwise it will default to use
     // aElement->NodePrincipal().
-    // This function returns true when aElement has 'loadingprincipal', so if
+    // This function returns true when aElement has 'triggeringprincipal', so if
     // setAttrs is true we will override the origin attributes on the channel
     // later.
     nsCOMPtr<nsIPrincipal> triggeringPrincipal;
-    bool setAttrs = nsContentUtils::GetLoadingPrincipalForXULNode(aElement,
-                                    aElement->mLoadingSrcTriggeringPrincipal,
-                                    getter_AddRefs(triggeringPrincipal));
+    bool setAttrs =
+      nsContentUtils::QueryTriggeringPrincipal(aElement,
+                                               aElement->mLoadingSrcTriggeringPrincipal,
+                                               getter_AddRefs(triggeringPrincipal));
 
     nsCOMPtr<nsILoadGroup> loadGroup = aElement->GetDocumentLoadGroup();
     nsCOMPtr<nsIChannel> channel;
     nsresult rv =
       NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel),
                                            aElement->mLoadingSrc,
                                            static_cast<Element*>(aElement),
                                            triggeringPrincipal,
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -758,43 +758,43 @@ ChannelMediaResource::RecreateChannel()
   nsSecurityFlags securityFlags = element->ShouldCheckAllowOrigin()
                                   ? nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS
                                   : nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
 
   MOZ_ASSERT(element->IsAnyOfHTMLElements(nsGkAtoms::audio, nsGkAtoms::video));
   nsContentPolicyType contentPolicyType = element->IsHTMLElement(nsGkAtoms::audio) ?
     nsIContentPolicy::TYPE_INTERNAL_AUDIO : nsIContentPolicy::TYPE_INTERNAL_VIDEO;
 
-  // If element has 'loadingprincipal' attribute, we will use the value as
-  // loadingPrincipal for the channel, otherwise it will default to use
+  // If element has 'triggeringprincipal' attribute, we will use the value as
+  // triggeringPrincipal for the channel, otherwise it will default to use
   // aElement->NodePrincipal().
-  // This function returns true when element has 'loadingprincipal', so if
+  // This function returns true when element has 'triggeringprincipal', so if
   // setAttrs is true we will override the origin attributes on the channel
   // later.
-  nsCOMPtr<nsIPrincipal> loadingPrincipal;
+  nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   bool setAttrs =
-    nsContentUtils::GetLoadingPrincipalForXULNode(element,
-                                                  getter_AddRefs(loadingPrincipal));
+    nsContentUtils::QueryTriggeringPrincipal(element,
+                                             getter_AddRefs(triggeringPrincipal));
 
   nsresult rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(mChannel),
                                                      mURI,
                                                      element,
-                                                     loadingPrincipal,
+                                                     triggeringPrincipal,
                                                      securityFlags,
                                                      contentPolicyType,
                                                      loadGroup,
                                                      nullptr,  // aCallbacks
                                                      loadFlags);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (setAttrs) {
     nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
     if (loadInfo) {
       // The function simply returns NS_OK, so we ignore the return value.
-      Unused << loadInfo->SetOriginAttributes(loadingPrincipal->OriginAttributesRef());
+      Unused << loadInfo->SetOriginAttributes(triggeringPrincipal->OriginAttributesRef());
    }
   }
 
   nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(mChannel));
   if (cos) {
     // Unconditionally disable throttling since we want the media to fluently
     // play even when we switch the tab to background.
     cos->AddClassFlags(nsIClassOfService::DontThrottle);
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -234,34 +234,38 @@ nsImageBoxFrame::UpdateImage()
   // get the new image src
   nsAutoString src;
   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
   mUseSrcAttr = !src.IsEmpty();
   if (mUseSrcAttr) {
     nsIDocument* doc = mContent->GetComposedDoc();
     if (doc) {
       nsContentPolicyType contentPolicyType;
-      nsCOMPtr<nsIPrincipal> loadingPrincipal;
+      nsCOMPtr<nsIPrincipal> triggeringPrincipal;
       uint64_t requestContextID = 0;
       nsContentUtils::GetContentPolicyTypeForUIImageLoading(mContent,
-                                                            getter_AddRefs(loadingPrincipal),
+                                                            getter_AddRefs(triggeringPrincipal),
                                                             contentPolicyType,
                                                             &requestContextID);
 
       nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
       nsCOMPtr<nsIURI> uri;
       nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
                                                 src,
                                                 doc,
                                                 baseURI);
       if (uri) {
-        nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc, loadingPrincipal, requestContextID,
-                                                doc->GetDocumentURI(), doc->GetReferrerPolicy(),
+        nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc,
+                                                triggeringPrincipal,
+                                                requestContextID,
+                                                doc->GetDocumentURI(),
+                                                doc->GetReferrerPolicy(),
                                                 mListener, mLoadFlags,
-                                                EmptyString(), getter_AddRefs(mImageRequest),
+                                                EmptyString(),
+                                                getter_AddRefs(mImageRequest),
                                                 contentPolicyType);
 
         if (NS_SUCCEEDED(rv) && mImageRequest) {
           nsLayoutUtils::RegisterImageRequestIfAnimated(presContext,
                                                         mImageRequest,
                                                         &mRequestRegistered);
         }
       }
--- a/toolkit/content/widgets/menu.xml
+++ b/toolkit/content/widgets/menu.xml
@@ -209,17 +209,17 @@
       <children includes="menupopup"/>
     </content>
   </binding>
 
   <binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
     <content>
       <xul:hbox class="menu-iconic-left" align="center" pack="center"
                 xbl:inherits="selected,_moz-menuactive,disabled,checked">
-        <xul:image class="menu-iconic-icon" xbl:inherits="src=image,loadingprincipal=iconloadingprincipal,validate,src"/>
+        <xul:image class="menu-iconic-icon" xbl:inherits="src=image,triggeringprincipal=iconloadingprincipal,validate,src"/>
       </xul:hbox>
       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
       <xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,accesskey,highlightable" crop="right"/>
       <children/>
       <xul:hbox class="menu-accel-container" anonid="accel">
         <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
       </xul:hbox>
     </content>
--- a/widget/cocoa/nsMenuItemIconX.h
+++ b/widget/cocoa/nsMenuItemIconX.h
@@ -51,17 +51,17 @@ public:
   // Destroy() should be called from mMenuObject's destructor to prevent
   // this from happening.  See bug 499600.
   void Destroy();
 
 protected:
   nsresult OnFrameComplete(imgIRequest* aRequest);
 
   nsCOMPtr<nsIContent>      mContent;
-  nsCOMPtr<nsIPrincipal>    mLoadingPrincipal;
+  nsCOMPtr<nsIPrincipal>    mTriggeringPrincipal;
   nsContentPolicyType       mContentType;
   RefPtr<imgRequestProxy> mIconRequest;
   nsMenuObjectX*            mMenuObject; // [weak]
   nsIntRect                 mImageRegionRect;
   bool                      mLoadedIcon;
   bool                      mSetIcon;
   NSMenuItem*               mNativeMenuItem; // [weak]
 };
--- a/widget/cocoa/nsMenuItemIconX.mm
+++ b/widget/cocoa/nsMenuItemIconX.mm
@@ -53,17 +53,17 @@ static const uint32_t kIconHeight = 16;
 typedef decltype(&nsIDOMRect::GetBottom) GetRectSideMethod;
 
 NS_IMPL_ISUPPORTS(nsMenuItemIconX, imgINotificationObserver)
 
 nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem,
                                  nsIContent*    aContent,
                                  NSMenuItem*    aNativeMenuItem)
 : mContent(aContent)
-, mLoadingPrincipal(aContent->NodePrincipal())
+, mTriggeringPrincipal(aContent->NodePrincipal())
 , mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE)
 , mMenuObject(aMenuItem)
 , mLoadedIcon(false)
 , mSetIcon(false)
 , mNativeMenuItem(aNativeMenuItem)
 {
   //  printf("Creating icon for menu item %d, menu %d, native item is %d\n", aMenuItem, aMenu, aNativeMenuItem);
 }
@@ -208,17 +208,17 @@ nsMenuItemIconX::GetIconURI(nsIURI** aIc
     if (primitiveType != nsIDOMCSSPrimitiveValue::CSS_URI)
       return NS_ERROR_FAILURE;
 
     rv = primitiveValue->GetStringValue(imageURIString);
     if (NS_FAILED(rv)) return rv;
   } else {
     uint64_t dummy = 0;
     nsContentUtils::GetContentPolicyTypeForUIImageLoading(mContent,
-                                                          getter_AddRefs(mLoadingPrincipal),
+                                                          getter_AddRefs(mTriggeringPrincipal),
                                                           mContentType,
                                                           &dummy);
   }
 
   // Empty the mImageRegionRect initially as the image region CSS could
   // have been changed and now have an error or have been removed since the
   // last GetIconURI call.
   mImageRegionRect.SetEmpty();
@@ -313,17 +313,17 @@ nsMenuItemIconX::LoadIcon(nsIURI* aIconU
     if (!sPlaceholderIconImage) return NS_ERROR_FAILURE;
 
     if (mNativeMenuItem)
       [mNativeMenuItem setImage:sPlaceholderIconImage];
   }
 
   nsresult rv = loader->LoadImage(aIconURI, nullptr, nullptr,
                                   mozilla::net::RP_Unset,
-                                  mLoadingPrincipal, 0, loadGroup, this,
+                                  mTriggeringPrincipal, 0, loadGroup, this,
                                   mContent, document, nsIRequest::LOAD_NORMAL, nullptr,
                                   mContentType, EmptyString(),
                                   /* aUseUrgentStartForChannel */ false,
                                   getter_AddRefs(mIconRequest));
   if (NS_FAILED(rv)) return rv;
 
   return NS_OK;