Skip to content
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
6 changes: 6 additions & 0 deletions fetch/cross-origin-resource-policy/resources/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main(request, response):
headers = [("Cross-Origin-Resource-Policy", request.GET['corp'])]
if 'origin' in request.headers:
headers.append(('Access-Control-Allow-Origin', request.headers['origin']))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're going to use this bit in a future test that checks the no-cors restrictions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this file is from #11171. I copied it here so the tests can run standalone and I don't have to include all prior commits making this harder to review.


return 200, headers, "hello"
18 changes: 18 additions & 0 deletions fetch/cross-origin-resource-policy/syntax.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// META: script=/common/get-host-info.sub.js

const crossOriginURL = get_host_info().HTTP_REMOTE_ORIGIN + "/fetch/cross-origin-resource-policy/resources/hello.py?corp=";

[
"same",
"same, same-origin",
"SAME-ORIGIN",
"Same-Origin",
"same-origin, <>",
"same-origin, same-origin"
].forEach(incorrectHeaderValue => {
// Note: an incorrect value results in a successful load, so this test is only meaningful in
// implementations with support for the header.
promise_test(t => {
return fetch(crossOriginURL + encodeURIComponent(incorrectHeaderValue), { mode: "no-cors" });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well check same-site as well, perhaps by adding {{hosts[alt][]}} to get-host-info.sub.js with some reasonable name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#11171 adds that. I guess once this all lands we could add same-site.

}, "Parsing Cross-Origin-Resource-Policy: " + incorrectHeaderValue);
});