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

Fetch: Access-Control-Expose-Headers: * #5047

Merged
merged 2 commits into from
Mar 7, 2017
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
14 changes: 14 additions & 0 deletions fetch/api/cors/cors-expose-star-worker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-expose-star.js?pipe=sub"));
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions fetch/api/cors/cors-expose-star.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="cors-expose-star.js?pipe=sub"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions fetch/api/cors/cors-expose-star.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}

const url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt",
sharedHeaders = "?pipe=header(Access-Control-Expose-Headers,*)|header(Test,X)|header(Set-Cookie,X)|"

promise_test(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Having looked for and not found the use of the argument, I removed it.

Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM

const headers = "header(Access-Control-Allow-Origin,*)"
return fetch(url + sharedHeaders + headers).then(resp => {
assert_equals(resp.status, 200)
assert_equals(resp.type , "cors")
assert_equals(resp.headers.get("test"), "X")
assert_equals(resp.headers.get("set-cookie"), null)
})
}, "Basic Access-Control-Expose-Headers: * support")

promise_test(() => {
const origin = location.origin, // assuming an ASCII origin
headers = "header(Access-Control-Allow-Origin," + origin + ")|header(Access-Control-Allow-Credentials,true)"
return fetch(url + sharedHeaders + headers, { credentials:"include" }).then(resp => {
assert_equals(resp.status, 200)
assert_equals(resp.type , "cors")
assert_equals(resp.headers.get("content-type"), "text/plain") // safelisted
assert_equals(resp.headers.get("test"), null)
assert_equals(resp.headers.get("set-cookie"), null)
})
}, "Cannot use * for credentialed fetches")
Copy link
Member

Choose a reason for hiding this comment

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

Good, this also gives me some confidence that the above test will pass if the feature is implemented 👍


done();