Bug 1257601 - Make subtest names stable for a fetch api test, r=Ms2ger

MozReview-Commit-ID: Gf66UU9gaqL

--HG--
extra : rebase_source : 0d2060c356987e3162cc9a7a61c08924b8cac1a6
This commit is contained in:
James Graham 2016-03-17 17:51:56 +00:00
Родитель ee461f660d
Коммит 4d06a30807
1 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -4,9 +4,6 @@ if (this.document === undefined) {
}
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) {
@ -17,17 +14,15 @@ function checkFetchResponse(url, data, mime, size, desc) {
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);
@ -35,7 +30,9 @@ function checkKoUrl(url, method, 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();