tor-browser

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

close-worker-with-xhr-in-progress.html (866B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 async_test(t => {
      8  function workerCode(origin) {
      9    const xhr = new XMLHttpRequest();
     10    xhr.open('GET', origin + '/xhr/resources/image.gif?pipe=trickle(100:d2)', true);
     11    xhr.responseType = 'blob';
     12    xhr.send();
     13    postMessage('sent');
     14  }
     15 
     16  const workerBlob = new Blob([workerCode.toString() + ";workerCode('" + location.origin + "');"], {type:"application/javascript"});
     17  const w = new Worker(URL.createObjectURL(workerBlob));
     18  w.onmessage = t.step_func(e => {
     19    assert_equals(e.data, 'sent');
     20    t.step_timeout(t.step_func(() => {
     21      w.terminate();
     22      t.step_timeout(t.step_func_done(() => {}), 500);
     23    }, 100));
     24  });
     25 }, 'Terminating a worker with a XHR in progress doesn\'t crash');
     26 </script>