tor-browser

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

sync-xhr-and-window-onload.html (774B)


      1 <!doctype html>
      2 <body>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6 async_test((t) => {
      7  let onloadIsCalled = false;
      8  window.addEventListener('load', () => {
      9    onloadIsCalled = true;
     10  }, {once: true});
     11  document.addEventListener('readystatechange', t.step_func(() => {
     12    if (document.readyState !== 'complete') {
     13      return;
     14    }
     15    const xhr = new XMLHttpRequest();
     16    xhr.open('GET', 'resources/pass.txt', false /* async */);
     17    xhr.send();
     18    assert_false(onloadIsCalled);
     19    // The load event eventually arrives.
     20    window.addEventListener('load', t.step_func_done(() => {
     21    }), {once: 'true'});
     22  }));
     23 }, 'sync XHR should not fire window.onload synchronously');
     24 </script>
     25 </body>