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