delaytest.html 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // This loads a externally specified image, forces a draw (in case of
  11. // decode-on-draw), waits 350ms, and then triggers the reftest snapshot.
  12. // This allows the animation on the page to complete.
  13. //
  14. // Use as "delaytest.html?animation.png"
  15. //
  16. // Get the image URL from our URL
  17. var imgURL = document.location.search.substr(1);
  18. // Load the image
  19. var img = document.images[0];
  20. img.src = imgURL;
  21. img.onload = forceDecode;
  22. img.onerror = forceDecode;
  23. function forceDecode() {
  24. try {
  25. // We need to force drawing of the image in an invisible context
  26. var canvas = document.createElement("canvas");
  27. var ctx = canvas.getContext("2d");
  28. ctx.drawImage(img, 0, 0);
  29. } catch(e) {}
  30. // We've force the decode. start the timer to trigger the reftest
  31. startTimer();
  32. }
  33. function startTimer() {
  34. const delay = 350;
  35. setTimeout("document.documentElement.className = '';", delay);
  36. }
  37. </script>
  38. </body>
  39. </html>