Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/headers-errors.html

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/headers-errors.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/headers-errors.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/headers-errors.html
new file mode 100644
index 0000000000000000000000000000000000000000..194ff32f1559f2dd9b5903eb3738c17c061c7172
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/headers-errors.html
@@ -0,0 +1,107 @@
+<!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>

Powered by Google App Engine
This is Rietveld 408576698