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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-error.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/request/request-error.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-error.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-error.html
new file mode 100644
index 0000000000000000000000000000000000000000..0339ae1526b2a502b896523dd5619dc62a0242b0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-error.html
@@ -0,0 +1,114 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Request error</title>
+ <meta name="help" href="https://fetch.spec.whatwg.org/#request">
+ <meta name="help" href="https://fetch.spec.whatwg.org/#body-mixin">
+ <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 Request("", {"window" : "http://test.url"}); },
+ "Expect TypeError exception");
+ },"RequestInit's window is not null");
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("http://:not a valid URL"); },
+ "Expect TypeError exception");
+ },"Input URL is not valid")
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("http://user:pass@test.url"); },
+ "Expect TypeError exception");
+ },"Input URL has credentials");
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("", {"referrer" : "http://:not a valid URL"}); },
+ "Expect TypeError exception");
+ },"RequestInit's referrer is invalid");
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("", {"method" : "IN VALID"}); },
+ "Expect TypeError exception");
+ }, "RequestInit's method is invalid");
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("", {"method" : "TRACE"}); },
+ "Expect TypeError exception");
+ }, "RequestInit's method is forbidden");
+
+ test(function() {
+ assert_throws(new TypeError() , function() { new Request("", {"mode" : "no-cors", "method" : "PUT"}); },
+ "Expect TypeError exception");
+ },"RequestInit's mode is no-cors and method is not simple");
+
+ test(function() {
+ assert_throws(new TypeError() ,
+ function() { new Request("", {"mode" : "no-cors", "integrity" : "not an empty string"}); },
+ "Expect TypeError exception");
+ },"RequestInit's mode is no-cors and integrity is not empty");
+
+ test(function() {
+ assert_throws(new TypeError() ,
+ function() { new Request("", {"mode" : "cors", "cache" : "only-if-cached"}); },
+ "Expect TypeError exception");
+ },"RequestInit's cache mode is only-if-cached and mode is not same-origin");
+
+ test(function() {
+ var initialHeaders = new Headers([["Content-Type", "potato"]]);
+ var initialRequest = new Request("", {"headers" : initialHeaders});
+ var request = new Request(initialRequest);
+ assert_equals(request.headers.get("Content-Type"), "potato");
+ }, "Request should get its content-type from the init request");
+
+ test(function() {
+ var initialHeaders = new Headers([["Content-Type", "potato"]]);
+ var initialRequest = new Request("", {"headers" : initialHeaders});
+ var headers = new Headers([]);
+ var request = new Request(initialRequest, {"headers" : headers});
+ assert_false(request.headers.has("Content-Type"));
+ }, "Request should not get its content-type from the init request if init headers are provided");
+
+ test(function() {
+ var initialHeaders = new Headers([["Content-Type-Extra", "potato"]]);
+ var initialRequest = new Request("", {"headers" : initialHeaders, "body" : "this is my plate", "method" : "POST"});
+ var request = new Request(initialRequest);
+ assert_equals(request.headers.get("Content-Type"), "text/plain;charset=UTF-8");
+ }, "Request should get its content-type from the body if none is provided");
+
+ test(function() {
+ var initialHeaders = new Headers([["Content-Type", "potato"]]);
+ var initialRequest = new Request("", {"headers" : initialHeaders, "body" : "this is my plate", "method" : "POST"});
+ var request = new Request(initialRequest);
+ assert_equals(request.headers.get("Content-Type"), "potato");
+ }, "Request should get its content-type from init headers if one is provided");
+
+ var parameters = ["referrerPolicy", "mode", "credentials", "cache", "redirect"];
+ parameters.forEach(function(parameter) {
+ test(function() {
+ var options = { };
+ options[parameter] = "BAD";
+ assert_throws(new TypeError(), function() { new Request("", options); });
+ },"Bad " + parameter +" init parameter value");
+ });
+
+ function testOnlyIfCachedMode(fetchMode, ok) {
+ test(function() {
+ var options = {"cache": "only-if-cached", "mode": fetchMode};
+ if (ok)
+ new Request("test", options);
+ else
+ assert_throws(new TypeError(), function() { new Request("test", options); });
+ }, "Request with cache mode: only-if-cached and fetch mode: " + fetchMode);
+ }
+ testOnlyIfCachedMode("same-origin", true);
+ testOnlyIfCachedMode("cors", false);
+ testOnlyIfCachedMode("no-cors", false);
+
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698