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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 if (this.document === undefined) {
2 importScripts("/resources/testharness.js");
3 importScripts("../resources/utils.js");
4 }
5
6 function checkFetchResponse(url, method, desc) {
7 if (!desc) {
8 var cut = (url.length >= 40) ? "[...]" : "";
9 cut += " (" + method + ")"
10 desc = "Fetching " + url.substring(0, 40) + cut + " is OK"
11 }
12 promise_test(function(test) {
13 return fetch(url, { method: method }).then(function(resp) {
14 assert_equals(resp.status, 200, "HTTP status is 200");
15 assert_equals(resp.type, "basic", "response type is basic");
16 assert_equals(resp.headers.get("Content-Type"), "text/html;charset=utf-8", "Content-Type is " + resp.headers.get("Content-Type"));
17 return resp.text();
18 })
19 }, desc);
20 }
21
22 checkFetchResponse("about:blank", "GET");
23 checkFetchResponse("about:blank", "PUT");
24 checkFetchResponse("about:blank", "POST");
25
26 function checkKoUrl(url, desc) {
27 if (!desc)
28 desc = "Fetching " + url.substring(0, 45) + " is KO"
29 promise_test(function(test) {
30 var promise = fetch(url);
31 return promise_rejects(test, new TypeError(), promise);
32 }, desc);
33 }
34
35 checkKoUrl("about:invalid.com");
36 checkKoUrl("about:config");
37 checkKoUrl("about:unicorn");
38
39 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698