tor-browser

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

delaytest.html (1282B)


      1 <!DOCTYPE HTML>
      2 <html class="reftest-wait">
      3 <head>
      4 <title>Delayed image reftest wrapper</title>
      5 </head>
      6 <body>
      7 <!-- non-empty alt to avoid the broken image icon -->
      8 <img id="image1" alt=" ">
      9 <script>
     10 
     11 window.addEventListener("MozReftestInvalidate", reftestInvalidateListener);
     12 
     13 // This loads a externally specified image, forces a draw (in case of
     14 // decode-on-draw), waits 100ms, and then triggers the reftest snapshot.
     15 // This allows the animation on the page to complete.
     16 //
     17 // Use as "delaytest.html?animation.png"
     18 //
     19 
     20 // Get the image URL from our URL
     21 var imgURL = document.location.search.substr(1);
     22 
     23 // Load the image
     24 var img = document.images[0];
     25 img.src = imgURL;
     26 img.onload = forceDecode;
     27 
     28 let decodeComplete = false;
     29 let gotReftestInvalidate = false;
     30 
     31 function forceDecode() {
     32  img.decode().then(function() {
     33    decodeComplete = true;
     34    maybeStartTimer();
     35  }, function() {
     36    decodeComplete = true;
     37    maybeStartTimer();
     38  });
     39 }
     40 
     41 function reftestInvalidateListener() {
     42  gotReftestInvalidate = true;
     43  maybeStartTimer();
     44 }
     45 
     46 function maybeStartTimer() {
     47  if (decodeComplete && gotReftestInvalidate) {
     48    startTimer();
     49  }
     50 }
     51 
     52 function startTimer() {
     53  const delay = 500;
     54  setTimeout("document.documentElement.className = '';", delay);
     55 }
     56 </script>
     57 </body>
     58 </html>