OLD | NEW |
1 <!doctype HTML> | 1 <!doctype HTML> |
2 <body> | 2 <body> |
3 <div style="height: 2000px; width: 2000px;"> | 3 <div style="height: 2000px; width: 2000px;"> |
4 <div id="targetImage" style="width: 50px; height: 50px"> | 4 <div id="targetImage" style="width: 50px; height: 50px"> |
5 </div> | 5 </div> |
6 <img id="testTarget" style="visibility: hidden"> | 6 <img id="testTarget" style="visibility: hidden"> |
7 <script src="../../fast/repaint/resources/text-based-repaint.js"></script> | 7 <script src="../../fast/repaint/resources/text-based-repaint.js"></script> |
8 <script> | 8 <script> |
9 window.testIsAsync = true; | 9 window.testIsAsync = true; |
10 | 10 |
11 // Steps: | |
12 // 1. Load the image | |
13 // 2. Start tracking paint invalidation rects | |
14 // 3. Call layoutAndPaintAsyncThen (via runRepaintTest, which does this for us)
to draw a frame | |
15 // 4. Wait longer than 100ms, so that the timer between the first and second ani
mated GIF | |
16 // frame expires and a paint invalidation is issued on the animated GIF. (100
ms is the | |
17 // length of the first frame of the animation in the GIF file.) | |
18 // 5. Stop tracking paint invalidation rects (finishRepaintTest does this for us
) | |
19 | |
20 // These steps differ from a standard repaint test in that step 2 precedes step
3. | |
21 // This is critical because layoutAndPaintAsyncThen may take longer than the 100
ms of the timer, | |
22 // so we may miss it. | |
23 | |
24 function repaintTest() { | 11 function repaintTest() { |
25 setTimeout(finishRepaintTest, 150); | 12 window.internals.advanceImageAnimation(testTarget); |
| 13 requestAnimationFrame(function() { |
| 14 finishRepaintTest(); |
| 15 }); |
26 } | 16 } |
27 | 17 |
28 function targetImageOnload() { | 18 function targetImageOnload() { |
29 if (window.internals) | 19 window.internals.startTrackingRepaints(document); |
30 window.internals.startTrackingRepaints(document); | |
31 runRepaintTest(); | 20 runRepaintTest(); |
32 } | 21 } |
33 | 22 |
34 onload = function() { | 23 onload = function() { |
35 targetImage.style.background = "url(../../fast/backgrounds/resources/red-gre
en-animated.gif)"; | 24 targetImage.style.background = "url(../../fast/backgrounds/resources/red-gre
en-animated.gif)"; |
36 | 25 |
37 // Use a parallel image element has a hack to detect whether the image has l
oaded, and therefore | 26 // Use a parallel image element has a hack to detect whether the image has l
oaded, and therefore |
38 // we'll get a frame. | 27 // we'll get a frame. |
39 testTarget.onload = targetImageOnload; | 28 testTarget.onload = targetImageOnload; |
40 testTarget.src = "../../fast/backgrounds/resources/red-green-animated.gif"; | 29 testTarget.src = "../../fast/backgrounds/resources/red-green-animated.gif"; |
41 } | 30 } |
42 </script> | 31 </script> |
OLD | NEW |