parsing.window.js (664B)
1 promise_test(() => { 2 return fetch("resources/content-lengths.json").then(res => res.json()).then(runTests); 3 }, "Loading JSONā¦"); 4 5 function runTests(testUnits) { 6 testUnits.forEach(({ input, output }) => { 7 promise_test(t => { 8 const result = fetch(`resources/content-length.py?length=${encodeURIComponent(input)}`); 9 if (output === null) { 10 return promise_rejects_js(t, TypeError, result); 11 } else { 12 return result.then(res => res.text()).then(text => { 13 assert_equals(text.length, output); 14 }); 15 } 16 }, `Input: ${format_value(input)}. Expected: ${output === null ? "network error" : output}.`); 17 }); 18 }