File: setrequestheader-bogus-name.htm

package info (click to toggle)
icedove 1%3A45.8.0-3~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,488,584 kB
  • ctags: 1,068,813
  • sloc: cpp: 4,801,496; ansic: 1,929,291; python: 379,296; java: 252,018; xml: 173,182; asm: 146,741; sh: 89,229; makefile: 23,462; perl: 16,380; objc: 4,088; yacc: 1,841; lex: 1,222; exp: 499; php: 437; lisp: 228; awk: 152; pascal: 116; sed: 51; ruby: 47; csh: 31; ada: 16
file content (48 lines) | stat: -rw-r--r-- 2,087 bytes parent folder | download | duplicates (3)
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
43
44
45
46
47
48
<!doctype html>
<html>
  <head>
    <title>XMLHttpRequest: setRequestHeader() name argument checks</title>
    <meta charset="utf-8">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[3]" />
  </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>
      function try_name(name) {
        test(function() {
          var client = new XMLHttpRequest()
          client.open("GET", "...")
          assert_throws("SyntaxError", function() { client.setRequestHeader(name, 'x-value') })
        }, "setRequestHeader should throw with header name " + format_value(invalid_headers[i]) + ".")
      }
      var invalid_headers = ["(", ")", "<", ">", "@", ",", ";", ":", "\\",
                             "\"", "/", "[", "]", "?", "=", "{", "}", " ",
                             /* HT already tested in the loop below */
                             "\u007f", "テスト", "", "t\rt", "t\nt", "t: t", "t:t",
                             "t<t", "t t", " tt", ":tt", "\ttt", "\vtt", "t\0t",
                             "t\"t", "t,t", "t;t", "()[]{}", "a?B", "X-テスト", "a=B"]
      for (var i = 0; i < 32; ++i) {
        invalid_headers.push(String.fromCharCode(i))
      }
      for (var i = 0; i < invalid_headers.length; ++i) {
        try_name(invalid_headers[i])
      }

    </script>
  </body>
</html>