tor-browser

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

file_SlowPage.sjs (1155B)


      1 "use strict";
      2 
      3 let timer;
      4 
      5 const DELAY_MS = 5000;
      6 
      7 function handleRequest(request, response) {
      8   response.processAsync();
      9 
     10   response.setHeader("Content-Type", "text/html", false);
     11 
     12   // Include paint_listener.js so that we can call waitForAllPaintsFlushed
     13   // on the window in which this is opened.
     14   response.write(
     15     '<script type="text/javascript" src="/tests/SimpleTest/paint_listener.js"></script>'
     16   );
     17 
     18   // Allow the opening window to react to loading being complete.
     19   response.write('<body onload="window.opener.fullyLoaded()">');
     20 
     21   // Send half of the content.
     22   for (let i = 0; i < 100; ++i) {
     23     response.write("<p>Some text.</p>");
     24   }
     25 
     26   // Allow the opening window to react to being partially loaded.
     27   response.write("<script>window.opener.partiallyLoaded();</script>");
     28 
     29   // Wait for 5 seconds, then send the rest of the content.
     30   timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     31   timer.init(
     32     () => {
     33       for (let i = 0; i < 100; ++i) {
     34         response.write("<p>Some text.</p>");
     35       }
     36       response.write("</body>");
     37 
     38       response.finish();
     39     },
     40     DELAY_MS,
     41     Ci.nsITimer.TYPE_ONE_SHOT
     42   );
     43 }