Skip to content

Commit

Permalink
Bug 1504103 [wpt PR 13849] - Fetch: Access-Control-Expose-Headers par…
Browse files Browse the repository at this point in the history
…sing, a=testonly

Automatic update from web-platform-testsFetch: Access-Control-Expose-Headers parsing

See whatwg/fetch#814 for context.
--

wpt-commits: 645c0e8a5c028a613e7ad1732834100dbe946fc7
wpt-pr: 13849

UltraBlame original commit: b12ab8efbefe006789483f40036d4b1fe8eab05f
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent d0a2953 commit abeb452
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
promise_test(() => fetch("resources/access-control-expose-headers.json").then(res => res.json()).then(runTests), "Loading JSON…");

function runTests(allTestData) {
allTestData.forEach(testData => {
const encodedInput = encodeURIComponent(testData.input);
promise_test(() => {
const relativeURL = "resources/expose-headers.py?expose=" + encodedInput,
url = new URL(relativeURL, location.href).href.replace("://", "://élève.");
return fetch(url).then(res => {
assert_equals(res.headers.get("content-language"), "mkay");
assert_equals(res.headers.get("bb-8"), (testData.exposed ? "hey" : null));
});
}, "Parsing: " + encodedInput);
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"input": "access-control-expose-headers: BB-8",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers: bb-8,,@#$#%%&^&^*()()11!",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: bb-8, no no",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: @#$#%%&^&^*()()11!,bb-8",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: bb-8\r\nAccess-Control-Expose-Headers: no",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers: bb-8\r\nAccess-Control-Expose-Headers: no no",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: no\r\nAccess-Control-Expose-Headers: bb-8",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers:\r\nAccess-Control-Expose-Headers: bb-8",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers: ,bb-8",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers: bb-8\u000C",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: bb-8\u000B",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: bb-8\u000B,bb-8",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: 'bb-8'",
"exposed": false
},
{
"input": "Access-Control-Expose-Headers: 'bb-8',bb-8",
"exposed": true
},
{
"input": "Access-Control-Expose-Headers: \"bb-8\",bb-8",
"exposed": false
}
]
10 changes: 10 additions & 0 deletions testing/web-platform/tests/cors/resources/expose-headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def main(request, response):
response.add_required_headers = False
output = "HTTP/1.1 221 ALL YOUR BASE BELONG TO H1\r\n"
output += "Access-Control-Allow-Origin: *\r\n"
output += "BB-8: hey\r\n"
output += "Content-Language: mkay\r\n"
output += request.GET.first("expose") + "\r\n"
output += "\r\n"
response.writer.write(output)
response.close_connection = True

0 comments on commit abeb452

Please sign in to comment.