tor-browser

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

slow_content.sjs (1340B)


      1 // Make sure our timer stays alive.
      2 let gTimer;
      3 
      4 function handleRequest(request, response) {
      5   response.processAsync();
      6 
      7   response.setHeader("Content-Type", "text/html", false);
      8   response.setStatusLine(request.httpVersion, 200, "OK");
      9 
     10   // The id to be used for `getLastContentDisplayportFor`,
     11   // `scrollbar-width: none` is to avoid the scrollbar area is excluded from
     12   // the displayport.
     13   response.write(
     14     "<html id='iframe-html' style='scrollbar-width: none; height: 200vh;'>"
     15   );
     16   response.write("<script src='/tests/SimpleTest/SimpleTest.js'></script>");
     17   response.write("<script src='apz_test_utils.js'></script>");
     18   response.write("<body style='margin: 0; padding: 0;'>");
     19 
     20   // Send a bunch of block elements to make the content vertically scrollable.
     21   for (let i = 0; i < 100; ++i) {
     22     response.write("<p>Some text.</p>");
     23   }
     24 
     25   // Flush above changes first.
     26   response.write(
     27     "<script>document.documentElement.getBoundingClientRect();</script>"
     28   );
     29 
     30   // Now it's time to start the test.
     31   response.write("<script>window.parent.postMessage('ready', '*');</script>");
     32 
     33   gTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     34   gTimer.init(
     35     () => {
     36       response.write("</body>");
     37       response.write("</html>");
     38       response.finish();
     39     },
     40     3000,
     41     Ci.nsITimer.TYPE_ONE_SHOT
     42   );
     43 }