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

Unified 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, 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-blob.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-blob.js b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-blob.js
new file mode 100644
index 0000000000000000000000000000000000000000..9bf73a6936517c2a4cb2423cfc8e8d2e13c04f0e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/scheme-blob.js
@@ -0,0 +1,48 @@
+if (this.document === undefined) {
+ importScripts("/resources/testharness.js");
+ importScripts("../resources/utils.js");
+}
+
+function checkFetchResponse(url, data, mime, size, desc) {
+ promise_test(function(test) {
+ size = size.toString();
+ return fetch(url).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"), mime, "Content-Type is " + resp.headers.get("Content-Type"));
+ assert_equals(resp.headers.get("Content-Length"), size, "Content-Length is " + resp.headers.get("Content-Length"));
+ return resp.text();
+ }).then(function(bodyAsText) {
+ assert_equals(bodyAsText, data, "Response's body is " + data);
+ });
+ }, desc);
+}
+
+var blob = new Blob(["Blob's data"], { "type" : "text/plain" });
+checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain", blob.size,
+ "Fetching [GET] URL.createObjectURL(blob) is OK");
+
+function checkKoUrl(url, method, desc) {
+ promise_test(function(test) {
+ var promise = fetch(url, {"method": method});
+ return promise_rejects(test, new TypeError(), promise);
+ }, desc);
+}
+
+var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" });
+checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET",
+ "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO");
+
+var invalidRequestMethods = [
+ "POST",
+ "OPTIONS",
+ "HEAD",
+ "PUT",
+ "DELETE",
+ "INVALID",
+];
+invalidRequestMethods.forEach(function(method) {
+ checkKoUrl(URL.createObjectURL(blob2), method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO");
+});
+
+done();

Powered by Google App Engine
This is Rietveld 408576698