gecko-dev/testing/web-platform/tests/XMLHttpRequest/setrequestheader-invalid-arguments.htm
James Graham dda86cd70e Bug 945222 - Initial import of web-platform-tests testsuite 1/4: test data
--HG--
extra : rebase_source : d635a4f39c587d4d381b486dd63de747865b77a2
2014-09-04 12:48:31 +01:00

44 lines
1.7 KiB
HTML

<!doctype html>
<html>
<head>
<title>XMLHttpRequest: setRequestHeader() with invalid arguments</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<!--
CHAR = <any US-ASCII character (octets 0 - 127)>
CTL = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
SP = <US-ASCII SP, space (32)>
HT = <US-ASCII HT, horizontal-tab (9)>
token = 1*<any CHAR except CTLs or separators>
separators = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
field-name = token
-->
<script>
var invalid_headers = ["(", ")", "<", ">", "@", ",", ";", ":", "\\",
"\"", "/", "[", "]", "?", "=", "{", "}", " ",
/* HT already tested in the loop below */
"\u007f"]
for (var i = 0; i < 32; ++i) {
invalid_headers.push(String.fromCharCode(i))
}
for (var i = 0; i < invalid_headers.length; ++i) {
test(function() {
assert_throws("SyntaxError", function() {
var client = new XMLHttpRequest()
client.open("GET", "../common/text-plain.txt")
client.setRequestHeader(invalid_headers[i], "test")
})
}, "setRequestHeader should throw with header " +
format_value(invalid_headers[i]) + ".")
}
</script>
</body>
</html>