tor-browser

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

event-error.sub.any.js (935B)


      1 // META: title=XMLHttpRequest Test: event - error
      2 
      3 async_test(function(t) {
      4  var client = new XMLHttpRequest();
      5  client.onerror = t.step_func(function (e) {
      6    assert_true(e instanceof ProgressEvent);
      7    assert_equals(e.type, "error");
      8    t.done();
      9  });
     10 
     11  client.open('GET', 'http://nonexistent.{{host}}:{{ports[http][0]}}');
     12  client.send('null');
     13 }, 'onerror should be called');
     14 
     15 async_test((t) => {
     16  const xhr = new XMLHttpRequest();
     17  xhr.open('GET', 'resources/bad-chunk-encoding.py');
     18  xhr.addEventListener('load', t.unreached_func('load'));
     19  xhr.addEventListener('error', t.step_func((e) => {
     20    assert_equals(e.loaded, 0, 'loaded');
     21    assert_equals(e.total, 0, 'total');
     22  }));
     23  xhr.addEventListener('loadend', t.step_func_done((e) => {
     24    assert_equals(e.loaded, 0, 'loaded');
     25    assert_equals(e.total, 0, 'total');
     26  }));
     27  xhr.send();
     28 }, 'error while reading body should report zeros for loaded and total');