tor-browser

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

response-body-errors.any.js (835B)


      1 // This will transmit two chunks TEST_CHUNK and then garbage, which should result in an error.
      2 const url = "/fetch/api/resources/bad-chunk-encoding.py?ms=1&count=2";
      3 
      4 test(() => {
      5  client = new XMLHttpRequest();
      6  client.open("GET", url, false);
      7  assert_throws_dom("NetworkError", () => client.send());
      8 }, "Synchronous XMLHttpRequest should throw on bad chunk");
      9 
     10 async_test(t => {
     11  client = new XMLHttpRequest();
     12  client.open("GET", url, true);
     13  client.onreadystatechange = t.step_func(() => {
     14    if (client.readyState === 3) {
     15      assert_true(client.responseText.indexOf("TEST_CHUNK") !== -1);
     16    }
     17  });
     18  client.onerror = t.step_func_done(() => {
     19    assert_equals(client.responseText, "");
     20  });
     21  client.onload = t.unreached_func();
     22  client.send();
     23 }, "Asynchronous XMLHttpRequest should clear response on bad chunk");