processing.any.js (866B)
1 // META: global=window,worker 2 3 promise_test(() => fetch("resources/data-urls.json").then(res => res.json()).then(runDataURLTests), "Setup."); 4 function runDataURLTests(tests) { 5 for(let i = 0; i < tests.length; i++) { 6 const input = tests[i][0], 7 expectedMimeType = tests[i][1], 8 expectedBody = expectedMimeType !== null ? tests[i][2] : null; 9 promise_test(t => { 10 if(expectedMimeType === null) { 11 return promise_rejects_js(t, TypeError, fetch(input)); 12 } else { 13 return fetch(input).then(res => { 14 return res.arrayBuffer().then(body => { 15 assert_array_equals(new Uint8Array(body), expectedBody); 16 assert_equals(res.headers.get("content-type"), expectedMimeType); // We could assert this earlier, but this fails often 17 }); 18 }); 19 } 20 }, format_value(input)); 21 } 22 }