Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / fetch / api / headers / headers-combine.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>Headers nameshake</title>
6     <meta name="help" href="https://fetch.spec.whatwg.org/#headers">
7     <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
8     <script src="/resources/testharness.js"></script>
9     <script src="/resources/testharnessreport.js"></script>
10   </head>
11   <body>
12     <script>
13       var headerSeqCombine = [["single", "singleValue"],
14                               ["double", "doubleValue1"],
15                               ["double", "doubleValue2"],
16                               ["triple", "tripleValue1"],
17                               ["triple", "tripleValue2"],
18                               ["triple", "tripleValue3"]
19       ];
20       var expectedDict = {"single": "singleValue",
21                           "double": "doubleValue1, doubleValue2",
22                           "triple": "tripleValue1, tripleValue2, tripleValue3"
23       };
24
25       test(function() {
26         var headers = new Headers(headerSeqCombine);
27         for (name in expectedDict)
28           assert_equals(headers.get(name), expectedDict[name]);
29       }, "Create headers using same name for different values");
30
31       test(function() {
32         var headers = new Headers(headerSeqCombine);
33         for (name in expectedDict) {
34           assert_true(headers.has(name), "name: " + name + " has value(s)");
35           headers.delete(name);
36           assert_false(headers.has(name), "name: " + name + " has no value(s) anymore");
37         }
38       }, "Check delete and has methods when using same name for different values");
39
40       test(function() {
41         var headers = new Headers(headerSeqCombine);
42         for (name in expectedDict) {
43           headers.set(name,"newSingleValue");
44           assert_equals(headers.get(name), "newSingleValue", "name: " + name + " has value: newSingleValue");
45         }
46       }, "Check set methods when called with already used name");
47
48       test(function() {
49         var headers = new Headers(headerSeqCombine);
50         for (name in expectedDict) {
51           var value = headers.get(name);
52           headers.append(name,"newSingleValue");
53           assert_equals(headers.get(name), (value + ", " + "newSingleValue"));
54         }
55       }, "Check append methods when called with already used name");
56     </script>
57   </body>
58 </html>