Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0ea5139

Browse files
author
Butkovits Atila
committed
Backed out changeset de12da283e67 (bug 1668071) for build bustages on nsCSPContext.cpp. CLOSED TREE
1 parent 9ee7388 commit 0ea5139

5 files changed

Lines changed: 18 additions & 100 deletions

dom/security/nsCSPContext.cpp

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

dom/security/test/csp/file_csp_frame_ancestors_about_blank.html

Lines changed: 0 additions & 9 deletions
This file was deleted.

dom/security/test/csp/file_csp_frame_ancestors_about_blank.html^headers^

Lines changed: 0 additions & 2 deletions
This file was deleted.

dom/security/test/csp/mochitest.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,3 @@ support-files =
433433
file_upgrade_insecure_navigation_redirect_same_origin.html
434434
file_upgrade_insecure_navigation_redirect_cross_origin.html
435435
[test_csp_style_src_empty_hash.html]
436-
[test_csp_frame_ancestors_about_blank.html]
437-
support-files =
438-
file_csp_frame_ancestors_about_blank.html
439-
file_csp_frame_ancestors_about_blank.html^headers^

dom/security/test/csp/test_csp_frame_ancestors_about_blank.html

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)