Bug 1306241 - Use NeedsSubjectPrincipal in dom/html/* - part 1, r=ehsan

This commit is contained in:
Andrea Marchesini
2016-10-03 10:34:14 +02:00
parent 74be230b48
commit c25c38926b
11 changed files with 45 additions and 21 deletions

View File

@@ -79,13 +79,14 @@ nsresult
nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_PRECONDITION(aContentDocument, "Null out param");
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(GetContentDocument());
nsCOMPtr<nsIDOMDocument> document =
do_QueryInterface(GetContentDocument(Some(nsContentUtils::SubjectPrincipal())));
document.forget(aContentDocument);
return NS_OK;
}
nsIDocument*
nsGenericHTMLFrameElement::GetContentDocument()
nsGenericHTMLFrameElement::GetContentDocument(const Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
nsCOMPtr<nsPIDOMWindowOuter> win = GetContentWindow();
if (!win) {
@@ -98,8 +99,8 @@ nsGenericHTMLFrameElement::GetContentDocument()
}
// Return null for cross-origin contentDocument.
if (!nsContentUtils::SubjectPrincipal()->
SubsumesConsideringDomain(doc->NodePrincipal())) {
if (!aSubjectPrincipal.value()
->SubsumesConsideringDomain(doc->NodePrincipal())) {
return nullptr;
}
return doc;