Bug 1257601 - Make subtest names stable for a fetch api test, r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Thu, 17 Mar 2016 17:51:56 +0000
changeset 342040 a330ce532103e2777888f49f461c79cd06c03381
parent 342039 39d566b6138ebc9b46ce0d890f9cba5e90e24f7b
child 342041 b34c0c51ae702ae77f915d873081aefce052df50
push id13342
push userbmo:james@hoppipolla.co.uk
push dateFri, 18 Mar 2016 09:55:58 +0000
reviewersMs2ger
bugs1257601
milestone48.0a1
Bug 1257601 - Make subtest names stable for a fetch api test, r=Ms2ger MozReview-Commit-ID: Gf66UU9gaqL
testing/web-platform/tests/fetch/api/basic/scheme-blob.js
--- a/testing/web-platform/tests/fetch/api/basic/scheme-blob.js
+++ b/testing/web-platform/tests/fetch/api/basic/scheme-blob.js
@@ -1,41 +1,38 @@
 if (this.document === undefined) {
   importScripts("/resources/testharness.js");
   importScripts("../resources/utils.js");
 }
 
 function checkFetchResponse(url, data, mime, size, desc) {
-  if (!desc)
-    var cut = (url.length >= 45) ? "[...]" : "";
-    desc = "Fetching " + url.substring(0, 45) + cut + " is OK"
   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);
+checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain",  blob.size,
+                  "Fetching [GET] URL.createObjectURL(blob) is OK");
 
 function checkKoUrl(url, method, desc) {
-  if (!desc)
-    var cut = (url.length >= 45) ? "[...]" : "";
-    desc = "Fetching [" + method + "] " + url.substring(0, 45) + cut +  " is KO"
   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");
-checkKoUrl(URL.createObjectURL(blob2), "POST");
+checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET",
+          "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO");
+checkKoUrl(URL.createObjectURL(blob2), "POST",
+           "Fetching [POST] URL.createObjectURL(blob) is KO");
 
 done();