summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/fetch/api/headers/headers-casing.any.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/wpt/tests/fetch/api/headers/headers-casing.any.js')
-rw-r--r--test/wpt/tests/fetch/api/headers/headers-casing.any.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/wpt/tests/fetch/api/headers/headers-casing.any.js b/test/wpt/tests/fetch/api/headers/headers-casing.any.js
new file mode 100644
index 0000000..20b8a9d
--- /dev/null
+++ b/test/wpt/tests/fetch/api/headers/headers-casing.any.js
@@ -0,0 +1,54 @@
+// META: title=Headers case management
+// META: global=window,worker
+
+"use strict";
+
+var headerDictCase = {"UPPERCASE": "value1",
+ "lowercase": "value2",
+ "mixedCase": "value3",
+ "Content-TYPE": "value4"
+ };
+
+function checkHeadersCase(originalName, headersToCheck, expectedDict) {
+ var lowCaseName = originalName.toLowerCase();
+ var upCaseName = originalName.toUpperCase();
+ var expectedValue = expectedDict[originalName];
+ assert_equals(headersToCheck.get(originalName), expectedValue,
+ "name: " + originalName + " has value: " + expectedValue);
+ assert_equals(headersToCheck.get(lowCaseName), expectedValue,
+ "name: " + lowCaseName + " has value: " + expectedValue);
+ assert_equals(headersToCheck.get(upCaseName), expectedValue,
+ "name: " + upCaseName + " has value: " + expectedValue);
+}
+
+test(function() {
+ var headers = new Headers(headerDictCase);
+ for (const name in headerDictCase)
+ checkHeadersCase(name, headers, headerDictCase)
+}, "Create headers, names use characters with different case");
+
+test(function() {
+ var headers = new Headers();
+ for (const name in headerDictCase) {
+ headers.append(name, headerDictCase[name]);
+ checkHeadersCase(name, headers, headerDictCase);
+ }
+}, "Check append method, names use characters with different case");
+
+test(function() {
+ var headers = new Headers();
+ for (const name in headerDictCase) {
+ headers.set(name, headerDictCase[name]);
+ checkHeadersCase(name, headers, headerDictCase);
+ }
+}, "Check set method, names use characters with different case");
+
+test(function() {
+ var headers = new Headers();
+ for (const name in headerDictCase)
+ headers.set(name, headerDictCase[name]);
+ for (const name in headerDictCase)
+ headers.delete(name.toLowerCase());
+ for (const name in headerDictCase)
+ assert_false(headers.has(name), "header " + name + " should have been deleted");
+}, "Check delete method, names use characters with different case");