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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-blob.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, data, mime, size, desc) {
7 promise_test(function(test) {
8 size = size.toString();
9 return fetch(url).then(function(resp) {
10 assert_equals(resp.status, 200, "HTTP status is 200");
11 assert_equals(resp.type, "basic", "response type is basic");
12 assert_equals(resp.headers.get("Content-Type"), mime, "Content-Type is " + resp.headers.get("Content-Type"));
13 assert_equals(resp.headers.get("Content-Length"), size, "Content-Length is " + resp.headers.get("Content-Length"));
14 return resp.text();
15 }).then(function(bodyAsText) {
16 assert_equals(bodyAsText, data, "Response's body is " + data);
17 });
18 }, desc);
19 }
20
21 var blob = new Blob(["Blob's data"], { "type" : "text/plain" });
22 checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain", blob .size,
23 "Fetching [GET] URL.createObjectURL(blob) is OK");
24
25 function checkKoUrl(url, method, desc) {
26 promise_test(function(test) {
27 var promise = fetch(url, {"method": method});
28 return promise_rejects(test, new TypeError(), promise);
29 }, desc);
30 }
31
32 var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" });
33 checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET",
34 "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO ");
35
36 var invalidRequestMethods = [
37 "POST",
38 "OPTIONS",
39 "HEAD",
40 "PUT",
41 "DELETE",
42 "INVALID",
43 ];
44 invalidRequestMethods.forEach(function(method) {
45 checkKoUrl(URL.createObjectURL(blob2), method, "Fetching [" + method + "] URL. createObjectURL(blob) is KO");
46 });
47
48 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698