Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web platform test for CSP frame-ancestors with path #49722

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// META: script=support/frame-ancestors-test.sub.js
test = async_test("A 'frame-ancestors' CSP directive with a URL that includes a path should be ignored.");
testUrlWithPathIgnored();

Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,16 @@ function testNestedSandboxedIFrame(policy, parent, child, expectation) {
injectNestedIframe(policy, parent == SAME_ORIGIN ? "same" : "cross", child == SAME_ORIGIN ? "same" : "cross", expectation == EXPECT_LOAD ? "allowed" : "blocked", true /* isSandboxed */);
};
}

function testUrlWithPathIgnored() {
window.onload = function () {
// A policy with a URL with a path should block the load, because no
// origin matches against a source expression with a path. See
// https://issues.chromium.org/issues/40779556#comment12 and
// https://w3c.github.io/webappsec-csp/#frame-ancestors-navigation-response
// steps 6.2 and 6.3.
injectIFrame(SAMEORIGIN_ORIGIN + "/test", SAME_ORIGIN, EXPECT_BLOCK);
// The same policy with no path should allow the load (smoke test).
injectIFrame(SAMEORIGIN_ORIGIN, SAME_ORIGIN, EXPECT_LOAD);
};
}