Update web-platform-tests to revision c26470dac73f2df9d4822a0d3482f7eb1ebf57d9

This commit is contained in:
Anthony Ramine 2018-01-10 14:28:20 +01:00
parent 7de87c487b
commit 4d3c932c47
648 changed files with 9014 additions and 4821 deletions

View file

@ -0,0 +1,53 @@
// META: script=resources/fetch-tests.js
function fetch_should_succeed(test, request) {
return fetch(request).then(response => response.text());
}
function fetch_should_fail(test, url, method = 'GET') {
return promise_rejects(test, new TypeError, fetch(url, {method: method}));
}
fetch_tests('fetch', fetch_should_succeed, fetch_should_fail);
promise_test(t => {
const blob_contents = 'test blob contents';
const blob_type = 'image/png';
const blob = new Blob([blob_contents], {type: blob_type});
const url = URL.createObjectURL(blob);
return fetch(url).then(response => {
assert_equals(response.headers.get('Content-Type'), blob_type);
});
}, 'fetch should return Content-Type from Blob');
promise_test(t => {
const blob_contents = 'test blob contents';
const blob = new Blob([blob_contents]);
const url = URL.createObjectURL(blob);
const request = new Request(url);
// Revoke the object URL. Request should take a reference to the blob as
// soon as it receives it in open(), so the request succeeds even though we
// revoke the URL before calling fetch().
URL.revokeObjectURL(url);
return fetch_should_succeed(t, request).then(text => {
assert_equals(text, blob_contents);
});
}, 'Revoke blob URL after creating Request, will fetch');
promise_test(function(t) {
const blob_contents = 'test blob contents';
const blob = new Blob([blob_contents]);
const url = URL.createObjectURL(blob);
const result = fetch_should_succeed(t, url).then(text => {
assert_equals(text, blob_contents);
});
// Revoke the object URL. fetch should have already resolved the blob URL.
URL.revokeObjectURL(url);
return result;
}, 'Revoke blob URL after calling fetch, fetch should succeed');