Bug 1406278: Part 6 - Use subject principal as triggering principal in <source> "srcset" attribute for <picture>. r=bz

MozReview-Commit-ID: DFq3k9PSOgA
This commit is contained in:
Kris Maglione
2017-10-05 15:59:15 -07:00
parent a3d15ab9ad
commit 6efed59589
5 changed files with 26 additions and 4 deletions

View File

@@ -1044,6 +1044,8 @@ HTMLImageElement::PictureSourceSrcsetChanged(nsIContent *aSourceNode,
nsCOMPtr<nsIPrincipal> principal;
if (aSourceNode == this) {
principal = mSrcsetTriggeringPrincipal;
} else if (auto* source = HTMLSourceElement::FromContent(aSourceNode)) {
principal = source->GetSrcsetTriggeringPrincipal();
}
mResponsiveSelector->SetCandidatesFromSourceSet(aNewValue, principal);
}
@@ -1238,6 +1240,8 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode)
if (!SourceElementMatches(aSourceNode)) {
return false;
}
auto* source = HTMLSourceElement::FromContent(aSourceNode);
principal = source->GetSrcsetTriggeringPrincipal();
} else if (aSourceNode->IsHTMLElement(nsGkAtoms::img)) {
// Otherwise this is the <img> tag itself
MOZ_ASSERT(aSourceNode == this);