| <html> |
| <head> |
| <style type="text/css"> |
| #test1 div { |
| height: 100px; |
| width: 100px; |
| } |
| #test1 .parent { |
| background-image: url(resources/animated.gif) |
| } |
| #test1 .child { |
| background-color: green; |
| } |
| |
| #test2 .parent { |
| position: relative; |
| height: 100px; |
| width: 100px; |
| background-image: url(resources/animated.gif); |
| background-repeat: no-repeat; |
| background-position: center; |
| } |
| |
| #test2 .child { |
| background-color: green; |
| position: relative; |
| left: 25px; |
| top: 25px; |
| height: 50px; |
| width: 50px; |
| } |
| #test3 img { |
| background-image: url(resources/animated.gif) |
| } |
| #test4 .parent { |
| position: relative; |
| height: 100px; |
| width: 100px; |
| background-color: red; |
| background-repeat: no-repeat; |
| background-position: center; |
| background-image: url(resources/animated.gif) |
| } |
| </style> |
| <script> |
| // Test that obscured animated gif does not trigger repaints. |
| if (window.testRunner) { |
| testRunner.waitUntilDone(); |
| testRunner.dumpAsText(); |
| } |
| |
| if (window.internals) { |
| internals.settings.setUseDefaultImageInterpolationQuality(true); |
| internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true; |
| } |
| |
| function finish() { |
| var layerTree = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS); |
| var invalidations = JSON.parse(layerTree).objectPaintInvalidations; |
| // Passes if there is no invalidations other than imgForAdvanceImageAnimation, |
| // or only invalidations because of background obscuration change. |
| // This is because before the delayed image decoder finishes decoding the image, |
| // we first assume the image is not opaque. If the image is found actually opaque |
| // after decoding, the background obscuration status of covered elements will |
| // change and cause paint invalidation. |
| var invalidatedObjects = {}; |
| if (invalidations) { |
| for (var i = 0; i < invalidations.length; ++i) { |
| var object = invalidations[i].object; |
| if (object.indexOf('imgForAdvanceImageAnimation') != -1) |
| continue; |
| if ((object.indexOf('target3') != -1 || object.indexOf('target4') != -1) && invalidations[i].reason == 'background obscuration change') |
| continue; |
| invalidatedObjects[object] = true; |
| } |
| } |
| |
| if (Object.keys(invalidatedObjects).length) |
| output.textContent = 'FAIL: Unexpected paint invalidations: ' + JSON.stringify(invalidatedObjects) + '\n' + layerTree; |
| else |
| output.textContent = 'PASS'; |
| testRunner.notifyDone(); |
| } |
| |
| function start() { |
| if (!window.testRunner || !window.internals) |
| return; |
| |
| // Ensure the deferred decoder has decoded resources/apple.jpg. |
| testRunner.capturePixelsAsyncThen(function() { |
| internals.startTrackingRepaints(document); |
| internals.advanceImageAnimation(imgForAdvanceImageAnimation); |
| testRunner.layoutAndPaintAsyncThen(function() { |
| internals.advanceImageAnimation(imgForAdvanceImageAnimation); |
| testRunner.layoutAndPaintAsyncThen(function() { |
| internals.advanceImageAnimation(imgForAdvanceImageAnimation); |
| testRunner.layoutAndPaintAsyncThen(finish); |
| }); |
| }); |
| }); |
| } |
| |
| </script> |
| </head> |
| <body onload="start()"> |
| <div id="test1"> |
| <div id="target1" class="parent"> |
| <div class="child"> |
| </div> |
| </div> |
| </div> |
| <div id="test2"> |
| <div id="target2" class="parent"> |
| <div class="child"> |
| </div> |
| </div> |
| </div> |
| <div id="test3"> |
| <img id="target3" src="resources/apple.jpg"> |
| </div> |
| <div id="test4"> |
| <div id="target4" class="parent"> |
| <a> |
| <div></div> |
| <div> |
| <img src="resources/apple.jpg"> |
| </div> |
| </a> |
| </div> |
| </div> |
| <img id="imgForAdvanceImageAnimation" src="resources/animated.gif"> |
| <pre id="output"></pre> |
| </body> |
| </html> |