diff options
Diffstat (limited to 'testing/web-platform/tests/fetch/api/headers')
7 files changed, 0 insertions, 566 deletions
diff --git a/testing/web-platform/tests/fetch/api/headers/headers-basic.html b/testing/web-platform/tests/fetch/api/headers/headers-basic.html deleted file mode 100644 index 98d71acad..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-basic.html +++ /dev/null @@ -1,221 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers structure</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#headers"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - test(function() { - new Headers(); - }, "Create headers from no parameter"); - - test(function() { - new Headers(undefined); - }, "Create headers from undefined parameter"); - - test(function() { - new Headers({}); - }, "Create headers from empty object"); - - var parameters = [null, 1]; - parameters.forEach(function(parameter) { - test(function() { - assert_throws(new TypeError(), function() { new Headers(parameter) }); - }, "Create headers with " + parameter + " should throw"); - }); - - var headerDict = {"name1": "value1", - "name2": "value2", - "name3": "value3", - "name4": null, - "name5": undefined, - "name6": 1, - "Content-Type": "value4" - }; - - var headerSeq = []; - for (var name in headerDict) - headerSeq.push([name, headerDict[name]]); - - test(function() { - var headers = new Headers(headerSeq); - for (name in headerDict) { - assert_equals(headers.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - } - assert_equals(headers.get("length"), null, "init should be treated as a sequence, not as a dictionary"); - }, "Create headers with sequence"); - - test(function() { - var headers = new Headers(headerDict); - for (name in headerDict) { - assert_equals(headers.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - } - }, "Create headers with OpenEndedDictionary"); - - test(function() { - var headers = new Headers(headerDict); - var headers2 = new Headers(headers); - for (name in headerDict) { - assert_equals(headers2.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - } - }, "Create headers with existing headers"); - - test(function() { - var headers = new Headers(); - for (name in headerDict) { - headers.append(name, headerDict[name]); - assert_equals(headers.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - } - }, "Check append method"); - - test(function() { - var headers = new Headers(); - for (name in headerDict) { - headers.set(name, headerDict[name]); - assert_equals(headers.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - } - }, "Check set method"); - - test(function() { - var headers = new Headers(headerDict); - for (name in headerDict) - assert_true(headers.has(name),"headers has name " + name); - - assert_false(headers.has("nameNotInHeaders"),"headers do not have header: nameNotInHeaders"); - }, "Check has method"); - - test(function() { - var headers = new Headers(headerDict); - for (name in headerDict) { - assert_true(headers.has(name),"headers have a header: " + name); - headers.delete(name) - assert_true(!headers.has(name),"headers do not have anymore a header: " + name); - } - }, "Check delete method"); - - test(function() { - var headers = new Headers(headerDict); - for (name in headerDict) - assert_equals(headers.get(name), String(headerDict[name]), - "name: " + name + " has value: " + headerDict[name]); - - assert_equals(headers.get("nameNotInHeaders"), null, "header: nameNotInHeaders has no value"); - }, "Check get method"); - - var headerEntriesDict = {"name1": "value1", - "Name2": "value2", - "name": "value3", - "content-Type": "value4", - "Content-Typ": "value5", - "Content-Types": "value6" - }; - var sortedHeaderDict = {}; - var headerValues = []; - var sortedHeaderKeys = Object.keys(headerEntriesDict).map(function(value) { - sortedHeaderDict[value.toLowerCase()] = headerEntriesDict[value]; - headerValues.push(headerEntriesDict[value]); - return value.toLowerCase(); - }).sort(); - - var iteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())); - function checkIteratorProperties(iterator) { - var prototype = Object.getPrototypeOf(iterator); - assert_equals(Object.getPrototypeOf(prototype), iteratorPrototype); - - var descriptor = Object.getOwnPropertyDescriptor(prototype, "next"); - assert_true(descriptor.configurable, "configurable"); - assert_true(descriptor.enumerable, "enumerable"); - assert_true(descriptor.writable, "writable"); - } - - test(function() { - var headers = new Headers(headerEntriesDict); - var actual = headers.keys(); - checkIteratorProperties(actual); - - sortedHeaderKeys.forEach(function(key) { - entry = actual.next(); - assert_false(entry.done); - assert_equals(entry.value, key); - }); - assert_true(actual.next().done); - assert_true(actual.next().done); - - for (key of headers.keys()) - assert_true(sortedHeaderKeys.indexOf(key) != -1); - }, "Check keys method"); - - test(function() { - var headers = new Headers(headerEntriesDict); - var actual = headers.values(); - checkIteratorProperties(actual); - - sortedHeaderKeys.forEach(function(key) { - entry = actual.next(); - assert_false(entry.done); - assert_equals(entry.value, sortedHeaderDict[key]); - }); - assert_true(actual.next().done); - assert_true(actual.next().done); - - for (value of headers.values()) - assert_true(headerValues.indexOf(value) != -1); - }, "Check values method"); - - test(function() { - var headers = new Headers(headerEntriesDict); - var actual = headers.entries(); - checkIteratorProperties(actual); - - sortedHeaderKeys.forEach(function(key) { - entry = actual.next(); - assert_false(entry.done); - assert_equals(entry.value[0], key); - assert_equals(entry.value[1], sortedHeaderDict[key]); - }); - assert_true(actual.next().done); - assert_true(actual.next().done); - - for (entry of headers.entries()) - assert_equals(entry[1], sortedHeaderDict[entry[0]]); - }, "Check entries method"); - - test(function() { - var headers = new Headers(headerEntriesDict); - var actual = headers[Symbol.iterator](); - - sortedHeaderKeys.forEach(function(key) { - entry = actual.next(); - assert_false(entry.done); - assert_equals(entry.value[0], key); - assert_equals(entry.value[1], sortedHeaderDict[key]); - }); - assert_true(actual.next().done); - assert_true(actual.next().done); - }, "Check Symbol.iterator method"); - - test(function() { - var headers = new Headers(headerEntriesDict); - var reference = sortedHeaderKeys[Symbol.iterator](); - headers.forEach(function(value, key, container) { - assert_equals(headers, container); - entry = reference.next(); - assert_false(entry.done); - assert_equals(key, entry.value); - assert_equals(value, sortedHeaderDict[entry.value]); - }); - assert_true(reference.next().done); - }, "Check forEach method"); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-casing.html b/testing/web-platform/tests/fetch/api/headers/headers-casing.html deleted file mode 100644 index 1e505d81c..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-casing.html +++ /dev/null @@ -1,64 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers case management</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#concept-header-list-append"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - 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 (name in headerDictCase) - checkHeadersCase(name, headers, headerDictCase) - }, "Create headers, names use characters with different case"); - - test(function() { - var headers = new Headers(); - for (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 (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 (name in headerDictCase) - headers.set(name, headerDictCase[name]); - for (name in headerDictCase) - headers.delete(name.toLowerCase()); - for (name in headerDictCase) - assert_false(headers.has(name), "header " + name + " should have been deleted"); - }, "Check delete method, names use characters with different case"); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-combine.html b/testing/web-platform/tests/fetch/api/headers/headers-combine.html deleted file mode 100644 index a0c15b0fe..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-combine.html +++ /dev/null @@ -1,60 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers nameshake</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#headers"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - var headerSeqCombine = [["single", "singleValue"], - ["double", "doubleValue1"], - ["double", "doubleValue2"], - ["triple", "tripleValue1"], - ["triple", "tripleValue2"], - ["triple", "tripleValue3"] - ]; - var expectedDict = {"single": "singleValue", - "double": "doubleValue1,doubleValue2", - "triple": "tripleValue1,tripleValue2,tripleValue3" - }; - - test(function() { - var headers = new Headers(headerSeqCombine); - for (name in expectedDict) - assert_equals(headers.get(name), expectedDict[name], - "name: " + name + " has value: " + expectedDict[name]); - }, "Create headers using same name for different values"); - - test(function() { - var headers = new Headers(headerSeqCombine); - for (name in expectedDict) { - assert_true(headers.has(name), "name: " + name + " has value(s)"); - headers.delete(name); - assert_false(headers.has(name), "name: " + name + " has no value(s) anymore"); - } - }, "Check delete and has methods when using same name for different values"); - - test(function() { - var headers = new Headers(headerSeqCombine); - for (name in expectedDict) { - headers.set(name,"newSingleValue"); - assert_equals(headers.get(name), "newSingleValue", "name: " + name + " has value: newSingleValue"); - } - }, "Check set methods when called with already used name"); - - test(function() { - var headers = new Headers(headerSeqCombine); - for (name in expectedDict) { - var value = headers.get(name); - headers.append(name,"newSingleValue"); - assert_equals(headers.get(name), (value + "," + "newSingleValue"), - "name: " + name + " has value: " + headers.get(name)); - } - }, "Check append methods when called with already used name"); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-errors.html b/testing/web-platform/tests/fetch/api/headers/headers-errors.html deleted file mode 100644 index 194ff32f1..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-errors.html +++ /dev/null @@ -1,107 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers errors</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#headers"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - - test(function() { - assert_throws(new TypeError() , function() { new Headers([["name"]]); }); - }, "Create headers giving an array having one string as init argument"); - - test(function() { - assert_throws(new TypeError() , function() { new Headers([["invalid", "invalidValue1", "invalidValue2"]]); }); - }, "Create headers giving an array having three strings as init argument"); - - test(function() { - assert_throws(new TypeError() , function() { new Headers([["invalidĀ", "Value1"]]); }); - }, "Create headers giving bad header name as init argument"); - - test(function() { - assert_throws(new TypeError() , function() { new Headers([["name", "invalidValueĀ"]]); }); - }, "Create headers giving bad header value as init argument"); - - var badNames = ["invalidĀ", {}]; - var badValues = ["invalidĀ"]; - - badNames.forEach(function(name) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.get(name); }); - }, "Check headers get with an invalid name " + name); - }); - - badNames.forEach(function(name) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.delete(name); }); - }, "Check headers delete with an invalid name " + name); - }); - - badNames.forEach(function(name) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.has(name); }); - }, "Check headers has with an invalid name " + name); - }); - - badNames.forEach(function(name) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.set(name, "Value1"); }); - }, "Check headers set with an invalid name " + name); - }); - - badValues.forEach(function(value) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.set("name", value); }); - }, "Check headers set with an invalid value " + value); - }); - - badNames.forEach(function(name) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.append("invalidĀ", "Value1"); }); - }, "Check headers append with an invalid name " + name); - }); - - badValues.forEach(function(value) { - test(function() { - var headers = new Headers(); - assert_throws(new TypeError() , function() { headers.append("name", value); }); - }, "Check headers append with an invalid value " + value); - }); - - test(function() { - var headers = new Headers([["name", "value"]]); - assert_throws(new TypeError() , function() { headers.forEach(); }); - assert_throws(new TypeError() , function() { headers.forEach(undefined); }); - assert_throws(new TypeError() , function() { headers.forEach(1); }); - }, "Headers forEach throws if argument is not callable"); - - test(function() { - var headers = new Headers([["name1", "value1"], ["name2", "value2"], ["name3", "value3"]]); - var counter = 0; - try { - headers.forEach(function(value, name) { - counter++; - if (name == "name2") - throw "error"; - }); - } catch (e) { - assert_equals(counter, 2); - assert_equals(e, "error"); - return; - } - assert_unreached(); - }, "Headers forEach loop should stop if callback is throwing exception"); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-idl.html b/testing/web-platform/tests/fetch/api/headers/headers-idl.html deleted file mode 100644 index 2aaa1ceea..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-idl.html +++ /dev/null @@ -1,36 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers idl interface</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#response"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <script src="/resources/WebIDLParser.js"></script> - <script src="/resources/idlharness.js"></script> - </head> - <body> - <script id="headers-idl" type="text/plain"> - typedef (Headers or sequence<sequence<ByteString>> or OpenEndedDictionary<ByteString>) HeadersInit; - - [Constructor(optional HeadersInit init), - Exposed=(Window,Worker)] - interface Headers { - void append(ByteString name, ByteString value); - void delete(ByteString name); - ByteString? get(ByteString name); - boolean has(ByteString name); - void set(ByteString name, ByteString value); - iterable<ByteString, ByteString>; - }; - </script> - <script> - var idlsArray = new IdlArray(); - var idl = document.getElementById("headers-idl").innerHTML - idlsArray.add_idls(idl); - idlsArray.add_objects({ Headers: ['new Headers()'] }); - idlsArray.test(); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-normalize.html b/testing/web-platform/tests/fetch/api/headers/headers-normalize.html deleted file mode 100644 index 6dfcf9d81..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-normalize.html +++ /dev/null @@ -1,47 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers normalize values</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#concept-header-value-normalize"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - var headerDictWS = {"name1": " space ", - "name2": "\ttab\t", - "name3": " spaceAndTab\t", - "name4": "\r\n newLine", //obs-fold cases - "name5": "newLine\r\n ", - "name6": "\r\n\tnewLine", - }; - - test(function() { - var headers = new Headers(headerDictWS); - for (name in headerDictWS) - assert_equals(headers.get(name), headerDictWS[name].trim(), - "name: " + name + " has normalized value: " + headerDictWS[name].trim()); - }, "Create headers with not normalized values"); - - test(function() { - var headers = new Headers(); - for (name in headerDictWS) { - headers.append(name, headerDictWS[name]); - assert_equals(headers.get(name), headerDictWS[name].trim(), - "name: " + name + " has value: " + headerDictWS[name].trim()); - } - }, "Check append method with not normalized values"); - - test(function() { - var headers = new Headers(); - for (name in headerDictWS) { - headers.set(name, headerDictWS[name]); - assert_equals(headers.get(name), headerDictWS[name].trim(), - "name: " + name + " has value: " + headerDictWS[name].trim()); - } - }, "Check set method with not normalized values"); - </script> - </body> -</html> diff --git a/testing/web-platform/tests/fetch/api/headers/headers-structure.html b/testing/web-platform/tests/fetch/api/headers/headers-structure.html deleted file mode 100644 index 9448e450c..000000000 --- a/testing/web-platform/tests/fetch/api/headers/headers-structure.html +++ /dev/null @@ -1,31 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title>Headers basic</title> - <meta name="help" href="https://fetch.spec.whatwg.org/#headers"> - <meta name="help" href="https://heycam.github.io/webidl/#idl-iterable"> - <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - </head> - <body> - <script> - var headers = new Headers(); - var methods = ["append", - "delete", - "get", - "has", - "set", - //Headers is iterable - "entries", - "keys", - "values" - ]; - for (var idx in methods) - test(function() { - assert_true(methods[idx] in headers, "headers has " + methods[idx] + " method"); - }, "Headers has " + methods[idx] + " method"); - </script> - </body> -</html> |