tor-browser

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

firing-events-http-content-length.html (954B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>ProgressEvent: firing events for HTTP with Content-Length</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7  </head>
      8  <body>
      9    <div id="log"></div>
     10    <script>
     11      async_test(t => {
     12        const xhr = new XMLHttpRequest();
     13        let progressHappened = false;
     14 
     15        xhr.onprogress = t.step_func(pe => {
     16          assert_equals(pe.type, "progress");
     17          assert_greater_than_equal(pe.loaded, 0, "loaded");
     18          assert_true(pe.lengthComputable, "lengthComputable");
     19          assert_equals(pe.total, 1300, "total");
     20          progressHappened = true;
     21        });
     22 
     23        xhr.onloadend = t.step_func_done(() => {
     24          assert_true(progressHappened);
     25        });
     26 
     27        xhr.open("GET", "resources/trickle.py?ms=0&count=100&specifylength=1", true);
     28        xhr.send(null);
     29      });
     30    </script>
     31  </body>
     32 </html>