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