@@ -1550,7 +1550,7 @@ nsCSPContext::PermitsAncestry(nsILoadInfo* aLoadInfo,
15501550 nsCOMPtr<nsIURI> uriClone;
15511551
15521552 while (ctx) {
1553- nsCOMPtr<nsIPrincipal> currentPrincipal ;
1553+ nsCOMPtr<nsIURI> currentURI ;
15541554 // Generally permitsAncestry is consulted from within the
15551555 // DocumentLoadListener in the parent process. For loads of type object
15561556 // and embed it's called from the Document in the content process.
@@ -1559,36 +1559,28 @@ nsCSPContext::PermitsAncestry(nsILoadInfo* aLoadInfo,
15591559 if (XRE_IsParentProcess ()) {
15601560 WindowGlobalParent* window = ctx->Canonical ()->GetCurrentWindowGlobal ();
15611561 if (window) {
1562- // Using the URI of the Principal and not the document because e.g.
1563- // about:blank inherits the principal and hence the URI of the
1564- // document does not reflect the security context of the document.
1565- currentPrincipal = window->DocumentPrincipal ();
1562+ currentURI = window->GetDocumentURI ();
15661563 }
15671564 } else if (nsPIDOMWindowOuter* windowOuter = ctx->GetDOMWindow ()) {
1568- currentPrincipal = nsGlobalWindowOuter::Cast ( windowOuter)-> GetPrincipal ();
1565+ currentURI = windowOuter-> GetDocumentURI ();
15691566 }
15701567
1571- if (currentPrincipal) {
1572- nsCOMPtr<nsIURI> currentURI;
1573- currentPrincipal->GetURI (getter_AddRefs (currentURI));
1574-
1575- if (currentURI) {
1576- nsAutoCString spec;
1577- currentURI->GetSpec (spec);
1578- // delete the userpass from the URI.
1579- rv = NS_MutateURI(currentURI)
1580- .SetRef (" " _ns)
1581- .SetUserPass (" " _ns)
1582- .Finalize (uriClone);
1583-
1584- // If setUserPass fails for some reason, just return a clone of the
1585- // current URI
1586- if (NS_FAILED(rv)) {
1587- rv = NS_GetURIWithoutRef(currentURI, getter_AddRefs (uriClone));
1588- NS_ENSURE_SUCCESS (rv, rv);
1589- }
1590- ancestorsArray.AppendElement (uriClone);
1568+ if (currentURI) {
1569+ nsAutoCString spec;
1570+ currentURI->GetSpec (spec);
1571+ // delete the userpass from the URI.
1572+ rv = NS_MutateURI(currentURI)
1573+ .SetRef (" " _ns)
1574+ .SetUserPass (" " _ns)
1575+ .Finalize (uriClone);
1576+
1577+ // If setUserPass fails for some reason, just return a clone of the
1578+ // current URI
1579+ if (NS_FAILED(rv)) {
1580+ rv = NS_GetURIWithoutRef(currentURI, getter_AddRefs (uriClone));
1581+ NS_ENSURE_SUCCESS (rv, rv);
15911582 }
1583+ ancestorsArray.AppendElement (uriClone);
15921584 }
15931585 ctx = ctx->GetParent ();
15941586 }
0 commit comments