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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-about.js

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/basic/scheme-about.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-about.js b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-about.js
new file mode 100644
index 0000000000000000000000000000000000000000..ddf711bf0a19fe128d91f582997024052cae8114
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-about.js
@@ -0,0 +1,39 @@
+if (this.document === undefined) {
+ importScripts("/resources/testharness.js");
+ importScripts("../resources/utils.js");
+}
+
+function checkFetchResponse(url, method, desc) {
+ if (!desc) {
+ var cut = (url.length >= 40) ? "[...]" : "";
+ cut += " (" + method + ")"
+ desc = "Fetching " + url.substring(0, 40) + cut + " is OK"
+ }
+ promise_test(function(test) {
+ return fetch(url, { method: method }).then(function(resp) {
+ assert_equals(resp.status, 200, "HTTP status is 200");
+ assert_equals(resp.type, "basic", "response type is basic");
+ assert_equals(resp.headers.get("Content-Type"), "text/html;charset=utf-8", "Content-Type is " + resp.headers.get("Content-Type"));
+ return resp.text();
+ })
+ }, desc);
+}
+
+checkFetchResponse("about:blank", "GET");
+checkFetchResponse("about:blank", "PUT");
+checkFetchResponse("about:blank", "POST");
+
+function checkKoUrl(url, desc) {
+ if (!desc)
+ desc = "Fetching " + url.substring(0, 45) + " is KO"
+ promise_test(function(test) {
+ var promise = fetch(url);
+ return promise_rejects(test, new TypeError(), promise);
+ }, desc);
+}
+
+checkKoUrl("about:invalid.com");
+checkKoUrl("about:config");
+checkKoUrl("about:unicorn");
+
+done();

Powered by Google App Engine
This is Rietveld 408576698