tor-browser

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

delaytest.html (1309B)


      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 350ms, 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 img.onerror = forceDecode;
     28 
     29 let decodeComplete = false;
     30 let gotReftestInvalidate = false;
     31 
     32 function forceDecode() {
     33  img.decode().then(function() {
     34    decodeComplete = true;
     35    maybeStartTimer();
     36  }, function() {
     37    decodeComplete = true;
     38    maybeStartTimer();
     39  });
     40 }
     41 
     42 function reftestInvalidateListener() {
     43  gotReftestInvalidate = true;
     44  maybeStartTimer();
     45 }
     46 
     47 function maybeStartTimer() {
     48  if (decodeComplete && gotReftestInvalidate) {
     49    startTimer();
     50  }
     51 }
     52 
     53 function startTimer() {
     54  const delay = 350;
     55  setTimeout("document.documentElement.className = '';", delay);
     56 }
     57 </script>
     58 </body>
     59 </html>