mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 21:28:04 +02:00
Automatic update from web-platform-tests
Replace some "promise_rejects(t, new FooError, stuff)" calls with promise_rejects_js.
This diff was generated by running:
find . -type f -print0 | xargs -0 perl -pi -e 'BEGIN { $/ = undef; } s/promise_rejects\(([ \n]*[a-zA-Z_]+[ \n]*,[ \n]*)(?:new )?([A-Z][A-Za-z]*Error) *(?:\(\))? *(, *.)/promise_rejects_js(\1\2\3/gs'
(which allows the optional "new" before "FooError" and an optional "()" after
it) and then:
1) Manually editing css/cssom-view/MediaQueryList-addListener-handleEvent.html
to make it get TypeError from the right global.
2) Manually editing fetch/api/response/response-error-from-stream.html to use
promise_rejects_exactly instead of the thing it was doing with a
CustomTestError.
3) Manually editing html/cross-origin-embedder-policy/require-corp.https.html
to use TypeError from the right global in the window.open case.
4) Manually editing
service-workers/service-worker/controller-with-no-fetch-event-handler.https.html
to use TypeError from the right global in the subframe case.
5) Manually editing
service-workers/service-worker/fetch-response-taint.https.html to use TypeError
from the right frame.
6) Manually editing
service-workers/service-worker/redirected-response.https.html to get the
TypeError from the right subframe in various places.
--
wpt-commits: ab733fd9f53eefdc034a2b96d08f080b355b6b10
wpt-pr: 21582
59 lines
1.7 KiB
HTML
59 lines
1.7 KiB
HTML
<!doctype html>
|
|
<meta charset=utf8>
|
|
<meta name=timeout content=long>
|
|
<title>Header value test</title>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<div id=log></div>
|
|
<script>
|
|
// Invalid values
|
|
[0, 0x0A, 0x0D].forEach(val => {
|
|
val = "x" + String.fromCharCode(val) + "x"
|
|
test(() => {
|
|
let xhr = new XMLHttpRequest()
|
|
xhr.open("POST", "/")
|
|
assert_throws_dom("SyntaxError", () => xhr.setRequestHeader("value-test", val))
|
|
}, "XMLHttpRequest with value " + encodeURI(val) + " needs to throw")
|
|
|
|
promise_test(t => promise_rejects_js(t, TypeError, fetch("/", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
|
|
})
|
|
|
|
// Valid values
|
|
let headerValues =[]
|
|
for(let i = 0; i < 0x100; i++) {
|
|
if(i === 0 || i === 0x0A || i === 0x0D) {
|
|
continue
|
|
}
|
|
headerValues.push("x" + String.fromCharCode(i) + "x")
|
|
}
|
|
var url = "../resources/inspect-headers.py?headers="
|
|
headerValues.forEach((_, i) => {
|
|
url += "val" + i + "|"
|
|
})
|
|
|
|
async_test((t) => {
|
|
let xhr = new XMLHttpRequest()
|
|
xhr.open("POST", url)
|
|
headerValues.forEach((val, i) => {
|
|
xhr.setRequestHeader("val" + i, val)
|
|
})
|
|
xhr.onload = t.step_func_done(() => {
|
|
headerValues.forEach((val, i) => {
|
|
assert_equals(xhr.getResponseHeader("x-request-val" + i), val)
|
|
})
|
|
})
|
|
xhr.send()
|
|
}, "XMLHttpRequest with all valid values")
|
|
|
|
promise_test((t) => {
|
|
const headers = new Headers
|
|
headerValues.forEach((val, i) => {
|
|
headers.append("val" + i, val)
|
|
})
|
|
return fetch(url, { headers }).then((res) => {
|
|
headerValues.forEach((val, i) => {
|
|
assert_equals(res.headers.get("x-request-val" + i), val)
|
|
})
|
|
})
|
|
}, "fetch() with all valid values")
|
|
</script>
|