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