OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Headers case management</title> |
| 6 <meta name="help" href="https://fetch.spec.whatwg.org/#concept-header-list-a
ppend"> |
| 7 <meta name="author" title="Canon Research France" href="https://www.crf.cano
n.fr"> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <script> |
| 13 var headerDictCase = {"UPPERCASE": "value1", |
| 14 "lowercase": "value2", |
| 15 "mixedCase": "value3", |
| 16 "Content-TYPE": "value4" |
| 17 }; |
| 18 |
| 19 function checkHeadersCase(originalName, headersToCheck, expectedDict) { |
| 20 var lowCaseName = originalName.toLowerCase(); |
| 21 var upCaseName = originalName.toUpperCase(); |
| 22 var expectedValue = expectedDict[originalName]; |
| 23 assert_equals(headersToCheck.get(originalName), expectedValue, |
| 24 "name: " + originalName + " has value: " + expectedValue); |
| 25 assert_equals(headersToCheck.get(lowCaseName), expectedValue, |
| 26 "name: " + lowCaseName + " has value: " + expectedValue); |
| 27 assert_equals(headersToCheck.get(upCaseName), expectedValue, |
| 28 "name: " + upCaseName + " has value: " + expectedValue); |
| 29 } |
| 30 |
| 31 test(function() { |
| 32 var headers = new Headers(headerDictCase); |
| 33 for (name in headerDictCase) |
| 34 checkHeadersCase(name, headers, headerDictCase) |
| 35 }, "Create headers, names use characters with different case"); |
| 36 |
| 37 test(function() { |
| 38 var headers = new Headers(); |
| 39 for (name in headerDictCase) { |
| 40 headers.append(name, headerDictCase[name]); |
| 41 checkHeadersCase(name, headers, headerDictCase); |
| 42 } |
| 43 }, "Check append method, names use characters with different case"); |
| 44 |
| 45 test(function() { |
| 46 var headers = new Headers(); |
| 47 for (name in headerDictCase) { |
| 48 headers.set(name, headerDictCase[name]); |
| 49 checkHeadersCase(name, headers, headerDictCase); |
| 50 } |
| 51 }, "Check set method, names use characters with different case"); |
| 52 |
| 53 test(function() { |
| 54 var headers = new Headers(); |
| 55 for (name in headerDictCase) |
| 56 headers.set(name, headerDictCase[name]); |
| 57 for (name in headerDictCase) |
| 58 headers.delete(name.toLowerCase()); |
| 59 for (name in headerDictCase) |
| 60 assert_false(headers.has(name), "header " + name + " should have been
deleted"); |
| 61 }, "Check delete method, names use characters with different case"); |
| 62 </script> |
| 63 </body> |
| 64 </html> |
OLD | NEW |