Loading browser/base/content/pageinfo/pageInfo.js +9 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ Components.utils.import("resource://gre/modules/LoadContextInfo.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "gSerializationHelper", "@mozilla.org/network/serialization-helper;1", "nsISerializationHelper"); // define a js object to implement nsITreeView function pageInfoTreeView(treeid, copycol) Loading Loading @@ -881,6 +886,8 @@ function makePreview(row) var newImage = new Image; newImage.id = "thepreviewimage"; let loadingPrincipalString = gSerializationHelper.serializeToString(gDocInfo.principal); newImage.setAttribute("loadingprincipal", loadingPrincipalString); var physWidth = 0, physHeight = 0; var width = 0, height = 0; Loading Loading @@ -928,6 +935,7 @@ function makePreview(row) else if (item.HTMLVideoElement && isProtocolAllowed) { newImage = document.createElementNS("http://www.w3.org/1999/xhtml", "video"); newImage.id = "thepreviewimage"; newImage.setAttribute("loadingprincipal", loadingPrincipalString); newImage.src = url; newImage.controls = true; width = physWidth = item.videoWidth; Loading @@ -939,6 +947,7 @@ function makePreview(row) else if (item.HTMLAudioElement && isProtocolAllowed) { newImage = new Audio; newImage.id = "thepreviewimage"; newImage.setAttribute("loadingprincipal", loadingPrincipalString); newImage.src = url; newImage.controls = true; isAudio = true; Loading dom/base/nsContentUtils.cpp +46 −17 Original line number Diff line number Diff line Loading @@ -3367,6 +3367,15 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsINode* aContext, NS_PRECONDITION(aLoadingPrincipal, "Must have a principal"); NS_PRECONDITION(aRequest, "Null out param"); // If the image is in a chrome document and the image node has been assigned a // "loadingprincipal" attribute, we should use that principal instead. if (IsSystemPrincipal(aLoadingPrincipal) && aContext->IsContent()) { nsContentPolicyType contentPolicyType; GetContentPolicyTypeForUIImageLoading(aContext->AsContent(), &aLoadingPrincipal, contentPolicyType); aContentPolicyType = (int32_t) contentPolicyType; } imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument); if (!imgLoader) { // nothing we can do here Loading Loading @@ -9879,8 +9888,9 @@ nsContentUtils::GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode, { // Use the serialized loadingPrincipal from the image element. Fall back // to mContent's principal (SystemPrincipal) if not available. aContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE; nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadingNode->NodePrincipal(); if (IsSystemPrincipal(loadingPrincipal)) { aContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE; nsAutoString imageLoadingPrincipal; aLoadingNode->GetAttr(kNameSpaceID_None, nsGkAtoms::loadingprincipal, imageLoadingPrincipal); Loading @@ -9899,5 +9909,24 @@ nsContentUtils::GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode, loadingPrincipal = aLoadingNode->NodePrincipal(); } } } loadingPrincipal.forget(aLoadingPrincipal); } /* static */ void nsContentUtils::ApplyCustomLoadPrincipalToChannel(Element* aElement, nsIChannel* aChannel) { nsCOMPtr<nsIPrincipal> loadingPrincipal = aElement->NodePrincipal(); if (loadingPrincipal && nsContentUtils::IsSystemPrincipal(loadingPrincipal)) { nsContentPolicyType dummyContentPolicyType; nsContentUtils::GetContentPolicyTypeForUIImageLoading( aElement, getter_AddRefs(loadingPrincipal), dummyContentPolicyType); NeckoOriginAttributes neckoAttrs; neckoAttrs.InheritFromDocToNecko( BasePrincipal::Cast(loadingPrincipal)->OriginAttributesRef()); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); if (loadInfo) { Unused << loadInfo->SetOriginAttributes(neckoAttrs); } } } dom/base/nsContentUtils.h +7 −0 Original line number Diff line number Diff line Loading @@ -2746,6 +2746,13 @@ public: nsIPrincipal** aLoadingPrincipal, nsContentPolicyType& aContentPolicyType); /** * If aElement has a "loadprincipal" attribute, apply the origin attributes * to the loadInfo belonging to aChannel. */ static void ApplyCustomLoadPrincipalToChannel(Element* aElement, nsIChannel* aChannel); private: static bool InitializeEventTable(); Loading dom/html/HTMLMediaElement.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,8 @@ public: return; } nsContentUtils::ApplyCustomLoadPrincipalToChannel(aElement, channel); // The listener holds a strong reference to us. This creates a // reference cycle, once we've set mChannel, which is manually broken // in the listener's OnStartRequest method after it is finished with Loading dom/media/MediaResource.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -833,6 +833,8 @@ ChannelMediaResource::RecreateChannel() loadFlags); NS_ENSURE_SUCCESS(rv, rv); nsContentUtils::ApplyCustomLoadPrincipalToChannel(element, mChannel); // We have cached the Content-Type, which should not change. Give a hint to // the channel to avoid a sniffing failure, which would be expected because we // are probably seeking in the middle of the bitstream, and sniffing relies Loading Loading
browser/base/content/pageinfo/pageInfo.js +9 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ Components.utils.import("resource://gre/modules/LoadContextInfo.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "gSerializationHelper", "@mozilla.org/network/serialization-helper;1", "nsISerializationHelper"); // define a js object to implement nsITreeView function pageInfoTreeView(treeid, copycol) Loading Loading @@ -881,6 +886,8 @@ function makePreview(row) var newImage = new Image; newImage.id = "thepreviewimage"; let loadingPrincipalString = gSerializationHelper.serializeToString(gDocInfo.principal); newImage.setAttribute("loadingprincipal", loadingPrincipalString); var physWidth = 0, physHeight = 0; var width = 0, height = 0; Loading Loading @@ -928,6 +935,7 @@ function makePreview(row) else if (item.HTMLVideoElement && isProtocolAllowed) { newImage = document.createElementNS("http://www.w3.org/1999/xhtml", "video"); newImage.id = "thepreviewimage"; newImage.setAttribute("loadingprincipal", loadingPrincipalString); newImage.src = url; newImage.controls = true; width = physWidth = item.videoWidth; Loading @@ -939,6 +947,7 @@ function makePreview(row) else if (item.HTMLAudioElement && isProtocolAllowed) { newImage = new Audio; newImage.id = "thepreviewimage"; newImage.setAttribute("loadingprincipal", loadingPrincipalString); newImage.src = url; newImage.controls = true; isAudio = true; Loading
dom/base/nsContentUtils.cpp +46 −17 Original line number Diff line number Diff line Loading @@ -3367,6 +3367,15 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsINode* aContext, NS_PRECONDITION(aLoadingPrincipal, "Must have a principal"); NS_PRECONDITION(aRequest, "Null out param"); // If the image is in a chrome document and the image node has been assigned a // "loadingprincipal" attribute, we should use that principal instead. if (IsSystemPrincipal(aLoadingPrincipal) && aContext->IsContent()) { nsContentPolicyType contentPolicyType; GetContentPolicyTypeForUIImageLoading(aContext->AsContent(), &aLoadingPrincipal, contentPolicyType); aContentPolicyType = (int32_t) contentPolicyType; } imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument); if (!imgLoader) { // nothing we can do here Loading Loading @@ -9879,8 +9888,9 @@ nsContentUtils::GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode, { // Use the serialized loadingPrincipal from the image element. Fall back // to mContent's principal (SystemPrincipal) if not available. aContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE; nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadingNode->NodePrincipal(); if (IsSystemPrincipal(loadingPrincipal)) { aContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE; nsAutoString imageLoadingPrincipal; aLoadingNode->GetAttr(kNameSpaceID_None, nsGkAtoms::loadingprincipal, imageLoadingPrincipal); Loading @@ -9899,5 +9909,24 @@ nsContentUtils::GetContentPolicyTypeForUIImageLoading(nsIContent* aLoadingNode, loadingPrincipal = aLoadingNode->NodePrincipal(); } } } loadingPrincipal.forget(aLoadingPrincipal); } /* static */ void nsContentUtils::ApplyCustomLoadPrincipalToChannel(Element* aElement, nsIChannel* aChannel) { nsCOMPtr<nsIPrincipal> loadingPrincipal = aElement->NodePrincipal(); if (loadingPrincipal && nsContentUtils::IsSystemPrincipal(loadingPrincipal)) { nsContentPolicyType dummyContentPolicyType; nsContentUtils::GetContentPolicyTypeForUIImageLoading( aElement, getter_AddRefs(loadingPrincipal), dummyContentPolicyType); NeckoOriginAttributes neckoAttrs; neckoAttrs.InheritFromDocToNecko( BasePrincipal::Cast(loadingPrincipal)->OriginAttributesRef()); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); if (loadInfo) { Unused << loadInfo->SetOriginAttributes(neckoAttrs); } } }
dom/base/nsContentUtils.h +7 −0 Original line number Diff line number Diff line Loading @@ -2746,6 +2746,13 @@ public: nsIPrincipal** aLoadingPrincipal, nsContentPolicyType& aContentPolicyType); /** * If aElement has a "loadprincipal" attribute, apply the origin attributes * to the loadInfo belonging to aChannel. */ static void ApplyCustomLoadPrincipalToChannel(Element* aElement, nsIChannel* aChannel); private: static bool InitializeEventTable(); Loading
dom/html/HTMLMediaElement.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,8 @@ public: return; } nsContentUtils::ApplyCustomLoadPrincipalToChannel(aElement, channel); // The listener holds a strong reference to us. This creates a // reference cycle, once we've set mChannel, which is manually broken // in the listener's OnStartRequest method after it is finished with Loading
dom/media/MediaResource.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -833,6 +833,8 @@ ChannelMediaResource::RecreateChannel() loadFlags); NS_ENSURE_SUCCESS(rv, rv); nsContentUtils::ApplyCustomLoadPrincipalToChannel(element, mChannel); // We have cached the Content-Type, which should not change. Give a hint to // the channel to avoid a sniffing failure, which would be expected because we // are probably seeking in the middle of the bitstream, and sniffing relies Loading