json.any.js (519B)
1 // See also /xhr/json.any.js 2 3 promise_test(async t => { 4 const response = await fetch(`data:,\uFEFF{ "b": 1, "a": 2, "b": 3 }`); 5 const json = await response.json(); 6 assert_array_equals(Object.keys(json), ["b", "a"]); 7 assert_equals(json.a, 2); 8 assert_equals(json.b, 3); 9 }, "Ensure the correct JSON parser is used"); 10 11 promise_test(async t => { 12 const response = await fetch("/xhr/resources/utf16-bom.json"); 13 return promise_rejects_js(t, SyntaxError, response.json()); 14 }, "Ensure UTF-16 results in an error");