summaryrefslogtreecommitdiffstats
path: root/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_setrequestheader-invalid-arguments.htm
blob: a077ad95f22291444864c5733d5a380dffb65121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!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 = ["(", ")", "<", ">", "@", ",", ";", ":", "\\",
                             "\"", "/", "[", "]", "?", "=", "{", "}", " ",
                             "\u0009", "\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("SYNTAX_ERR", function() {
            var client = new XMLHttpRequest()
            client.open("GET", "../resources/delay.php?ms=0")
            client.setRequestHeader(invalid_headers[i], "test")
          }, "setRequestHeader should throw with header " +
             format_value(invalid_headers[i]) +".")
        })
      }
    </script>
  </body>
</html>