blob: ecc8b99f0ef7e60120d9bc2427a10c089975e1d2 [file] [log] [blame]
Ms2ger0b5a9972011-03-03 21:35:101<!doctype html>
2<html>
3 <head>
4 <title>XMLHttpRequest: setRequestHeader() with invalid arguments</title>
5 <script src="/resources/testharness.js"></script>
Ms2gerace7f0f2011-06-04 16:24:096 <script src="/resources/testharnessreport.js"></script>
Ms2ger0b5a9972011-03-03 21:35:107 </head>
8 <body>
9 <div id="log"></div>
10<!--
11 CHAR = <any US-ASCII character (octets 0 - 127)>
12 CTL = <any US-ASCII control character
13 (octets 0 - 31) and DEL (127)>
14 SP = <US-ASCII SP, space (32)>
15 HT = <US-ASCII HT, horizontal-tab (9)>
16 token = 1*<any CHAR except CTLs or separators>
17 separators = "(" | ")" | "<" | ">" | "@"
18 | "," | ";" | ":" | "\" | <">
19 | "/" | "[" | "]" | "?" | "="
20 | "{" | "}" | SP | HT
21 field-name = token
22-->
23 <script>
24 var invalid_headers = ["(", ")", "<", ">", "@", ",", ";", ":", "\\",
25 "\"", "/", "[", "]", "?", "=", "{", "}", " ",
Ms2ger33d43652013-04-04 11:45:1826 /* HT already tested in the loop below */
27 "\u007f"]
Ms2ger0b5a9972011-03-03 21:35:1028 for (var i = 0; i < 32; ++i) {
29 invalid_headers.push(String.fromCharCode(i))
30 }
31 for (var i = 0; i < invalid_headers.length; ++i) {
32 test(function() {
Ms2ger33d43652013-04-04 11:45:1833 assert_throws("SyntaxError", function() {
Ms2ger0b5a9972011-03-03 21:35:1034 var client = new XMLHttpRequest()
Ms2ger33d43652013-04-04 11:45:1835 client.open("GET", "../common/text-plain.txt")
Ms2ger0b5a9972011-03-03 21:35:1036 client.setRequestHeader(invalid_headers[i], "test")
Ms2ger33d43652013-04-04 11:45:1837 })
38 }, "setRequestHeader should throw with header " +
39 format_value(invalid_headers[i]) + ".")
Ms2ger0b5a9972011-03-03 21:35:1040 }
41 </script>
42 </body>
43</html>