-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1499659 [wpt PR 13559] - Fetch: test nosniff parsing better, a=te…
…stonly Automatic update from web-platform-testsFetch: X-Content-Type-Options: nosniff parsing For whatwg/fetch#818. -- wpt-commits: 10f708e6f13141fc92ca9318c7606590f659fcf2 wpt-pr: 13559
- Loading branch information
1 parent
2fa1d1f
commit dcc2d3f
Showing
10 changed files
with
92 additions
and
66 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
testing/web-platform/tests/fetch/nosniff/parsing-nosniff.html
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
testing/web-platform/tests/fetch/nosniff/parsing-nosniff.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
promise_test(() => fetch("resources/x-content-type-options.json").then(res => res.json()).then(runTests), "Loading JSON…"); | ||
|
||
function runTests(allTestData) { | ||
for (let i = 0; i < allTestData.length; i++) { | ||
const testData = allTestData[i], | ||
input = encodeURIComponent(testData.input); | ||
async_test(t => { | ||
const script = document.createElement("script"); | ||
t.add_cleanup(() => script.remove()); | ||
// A <script> element loading a classic script does not care about the MIME type, unless | ||
// X-Content-Type-Options: nosniff is specified, in which case a JavaScript MIME type is | ||
// enforced, which x/x is not. | ||
if (testData.nosniff) { | ||
script.onerror = t.step_func_done(); | ||
script.onload = t.unreached_func("Script should not have loaded"); | ||
} else { | ||
script.onerror = t.unreached_func("Script should have loaded"); | ||
script.onload = t.step_func_done(); | ||
} | ||
script.src = "resources/nosniff.py?nosniff=" + input; | ||
document.body.appendChild(script); | ||
}, input); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
testing/web-platform/tests/fetch/nosniff/resources/nosniff-first.asis
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
testing/web-platform/tests/fetch/nosniff/resources/nosniff-last.asis
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
testing/web-platform/tests/fetch/nosniff/resources/nosniff-no-x.asis
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
testing/web-platform/tests/fetch/nosniff/resources/nosniff-quoted-single.asis
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
testing/web-platform/tests/fetch/nosniff/resources/nosniff-quoted.asis
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
testing/web-platform/tests/fetch/nosniff/resources/nosniff-uppercase.asis
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
testing/web-platform/tests/fetch/nosniff/resources/nosniff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 220 YOU HAVE NO POWER HERE\r\n" | ||
output += "Content-Length: 22\r\n" | ||
output += "Content-Type: x/x\r\n" | ||
output += request.GET.first("nosniff") + "\r\n" | ||
output += "\r\n" | ||
output += "// nothing to see here" | ||
response.writer.write(output) | ||
response.close_connection = True |
58 changes: 58 additions & 0 deletions
58
testing/web-platform/tests/fetch/nosniff/resources/x-content-type-options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"input": "X-Content-Type-Options: NOSNIFF", | ||
"nosniff": true | ||
}, | ||
{ | ||
"input": "x-content-type-OPTIONS: nosniff", | ||
"nosniff": true | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: nosniff,,@#$#%%&^&^*()()11!", | ||
"nosniff": true | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: @#$#%%&^&^*()()11!,nosniff", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: nosniff\r\nX-Content-Type-Options: no", | ||
"nosniff": true | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: no\r\nX-Content-Type-Options: nosniff", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options:\r\nX-Content-Type-Options: nosniff", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: ,nosniff", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: nosniff\u000C", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: nosniff\u000B", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: nosniff\u000B,nosniff", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: 'NosniFF'", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "X-Content-Type-Options: \"nosniFF\"", | ||
"nosniff": false | ||
}, | ||
{ | ||
"input": "Content-Type-Options: nosniff", | ||
"nosniff": false | ||
} | ||
] |