| OLD | NEW |
| 1 <script src="../../resources/run-after-layout-and-paint.js"></script> | 1 <script src="../../resources/run-after-layout-and-paint.js"></script> |
| 2 <script src="resources/composited-scroll.js"></script> |
| 2 <script> | 3 <script> |
| 3 if (window.internals) | 4 if (window.internals) |
| 4 internals.runtimeFlags.compositeOpaqueScrollersEnabled = true; | 5 internals.runtimeFlags.compositeOpaqueScrollersEnabled = true; |
| 5 | 6 |
| 6 if (window.testRunner) { | 7 if (window.testRunner) { |
| 7 testRunner.dumpAsTextWithPixelResults(); | 8 testRunner.dumpAsTextWithPixelResults(); |
| 8 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
| 9 } | 10 } |
| 10 | 11 |
| 11 function hasOpaqueCompositedScrollingContentsLayer(layer) { | |
| 12 if (layer.name == "Scrolling Contents Layer") | |
| 13 return layer.contentsOpaque; | |
| 14 if (layer.children) { | |
| 15 for (var i = 0; i < layer.children.length; i++) { | |
| 16 if (hasOpaqueCompositedScrollingContentsLayer(layer.children[i])
) | |
| 17 return true; | |
| 18 } | |
| 19 } | |
| 20 return false; | |
| 21 } | |
| 22 | |
| 23 function hasCompositedScrollingContentsLayer(layer) { | |
| 24 if (layer.name == "Scrolling Contents Layer") | |
| 25 return true; | |
| 26 if (layer.children) { | |
| 27 for (var i = 0; i < layer.children.length; i++) { | |
| 28 if (hasCompositedScrollingContentsLayer(layer.children[i])) | |
| 29 return true; | |
| 30 } | |
| 31 } | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 onload = function() { | 12 onload = function() { |
| 36 if (!window.testRunner || !window.internals) | 13 if (!window.testRunner || !window.internals) |
| 37 return; | 14 return; |
| 38 | 15 |
| 39 var result = "Should have opaque composited scrolling contents layer: "; | 16 var result = "Should have opaque composited scrolling contents layer: "; |
| 40 if (hasOpaqueCompositedScrollingContentsLayer(JSON.parse(window.internal
s.layerTreeAsText(document)))) | 17 if (hasOpaqueCompositedScrollingContentsLayer(JSON.parse(window.internal
s.layerTreeAsText(document)))) |
| 41 result += "Pass.\n"; | 18 result += "Pass.\n"; |
| 42 else | 19 else |
| 43 result += "Fail.\n"; | 20 result += "Fail.\n"; |
| 44 document.getElementById("test-1-output").innerHTML = result; | 21 document.getElementById("test-1-output").innerHTML = result; |
| 45 | 22 |
| 46 scrollerElement = document.getElementById("scroller"); | 23 scrollerElement = document.getElementById("scroller"); |
| 47 scrollerElement.style.background = "transparent local content-box"; | 24 scrollerElement.style.background = "transparent local content-box"; |
| 48 | 25 |
| 49 runAfterLayoutAndPaint(function() { | 26 runAfterLayoutAndPaint(function() { |
| 50 var result = "Should not have opaque composited scrolling contents l
ayer: "; | 27 var result = "Should not have opaque composited scrolling contents l
ayer: "; |
| 51 if (!hasCompositedScrollingContentsLayer(JSON.parse(window.internals
.layerTreeAsText(document)))) | 28 if (!isUsingCompositedScrolling(JSON.parse(window.internals.layerTre
eAsText(document)))) |
| 52 result += "Pass.\n"; | 29 result += "Pass.\n"; |
| 53 else | 30 else |
| 54 result += "Fail.\n"; | 31 result += "Fail.\n"; |
| 55 document.getElementById("test-2-output").innerHTML = result; | 32 document.getElementById("test-2-output").innerHTML = result; |
| 56 runAfterLayoutAndPaint(function() { testRunner.notifyDone(); }); | 33 runAfterLayoutAndPaint(function() { testRunner.notifyDone(); }); |
| 57 }); | 34 }); |
| 58 } | 35 } |
| 59 </script> | 36 </script> |
| 60 <style> | 37 <style> |
| 61 #scroller { | 38 #scroller { |
| 62 background: red local content-box; | 39 background: red local content-box; |
| 63 border: 10px solid rgba(0, 255, 0, 0.5); | 40 border: 10px solid rgba(0, 255, 0, 0.5); |
| 64 overflow: scroll; | 41 overflow: scroll; |
| 65 width: 200px; | 42 width: 200px; |
| 66 height: 200px; | 43 height: 200px; |
| 67 } | 44 } |
| 68 .spacer { | 45 .spacer { |
| 69 height: 300px; | 46 height: 300px; |
| 70 } | 47 } |
| 71 </style> | 48 </style> |
| 72 <div id="scroller"><div class="spacer"></div></div> | 49 <div id="scroller"><div class="spacer"></div></div> |
| 73 <p>Scroller background should be white</p> | 50 <p>Scroller background should be white</p> |
| 74 <p id="test-1-output"></p> | 51 <p id="test-1-output"></p> |
| 75 <p id="test-2-output"></p> | 52 <p id="test-2-output"></p> |
| 76 | 53 |
| OLD | NEW |