tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

json.any.js (724B)


      1 // See also /fetch/api/response/json.any.js
      2 
      3 async_test(t => {
      4  const xhr = new XMLHttpRequest();
      5  xhr.responseType = "json";
      6  xhr.open("GET", `data:,\uFEFF{ "b": 1, "a": 2, "b": 3 }`);
      7  xhr.send();
      8  xhr.onload = t.step_func_done(() => {
      9    assert_array_equals(Object.keys(xhr.response), ["b", "a"]);
     10    assert_equals(xhr.response.a, 2);
     11    assert_equals(xhr.response.b, 3);
     12  });
     13 }, "Ensure the correct JSON parser is used");
     14 
     15 async_test(t => {
     16  const client = new XMLHttpRequest();
     17  client.responseType = 'json';
     18  client.open("GET", "resources/utf16-bom.json");
     19  client.send();
     20  client.onload = t.step_func_done(() => {
     21    assert_equals(client.response, null);
     22  });
     23 }, "Ensure UTF-16 results in an error");