Skip to content

Fetch: basic syntax tests for Cross-Origin-Resource-Policy#11427

Merged
annevk merged 2 commits into
masterfrom
annevk/corp-syntax
Jun 18, 2018
Merged

Fetch: basic syntax tests for Cross-Origin-Resource-Policy#11427
annevk merged 2 commits into
masterfrom
annevk/corp-syntax

Conversation

@annevk

@annevk annevk commented Jun 8, 2018

Copy link
Copy Markdown
Member

Supplements #11171.

@annevk

annevk commented Jun 8, 2018

Copy link
Copy Markdown
Member Author

@youennf I based these on your tests (and copied your hello.py). If you want I suppose I could add equivalents for same-site. Not sure if we needed that from the get go.

annevk added a commit to whatwg/fetch that referenced this pull request Jun 8, 2018
This header makes it easier for sites to block unwanted "no-cors"
cross-origin requests.

Tests:

* web-platform-tests/wpt#11171
* web-platform-tests/wpt#11427
* web-platform-tests/wpt#11428

Follow-up: #760.

Fixes #687.

@mikewest mikewest left a comment

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.

LGTM!

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.

"same, same-origin",
"SAME-ORIGIN",
"Same-Origin",
"same-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.

same-origin, same-origin also seems interesting.

// 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.

@annevk annevk merged commit b7373b4 into master Jun 18, 2018
@annevk annevk deleted the annevk/corp-syntax branch June 18, 2018 12:58
annevk added a commit to whatwg/fetch that referenced this pull request Jun 18, 2018
This header makes it easier for sites to block unwanted "no-cors"
cross-origin requests.

Tests:

* web-platform-tests/wpt#11171
* web-platform-tests/wpt#11427
* web-platform-tests/wpt#11428

Follow-up: #760 & #767.

Fixes #687.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants