6 window
.testRunner
.dumpAsText();
9 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(false);
11 function hasScrollbarRepaint(layerTree
)
13 return hasScrollbarRepaintHelper(JSON
.parse(layerTree
));
16 function hasScrollbarRepaintHelper(jsonLayerTree
) {
17 var repaintRects
= jsonLayerTree
["repaintRects"];
19 for (var i
= 0; i
< repaintRects
.length
; ++i
) {
20 var width
= repaintRects
[i
][2];
21 var height
= repaintRects
[i
][3];
22 if (width
!= 15 || height
!= 285)
26 var children
= jsonLayerTree
["children"];
28 for (var i
= 0; i
< children
.length
; i
++) {
29 if (hasScrollbarRepaintHelper(children
[i
]))
36 function testRepaint() {
38 for (var testIteration
= 0; testIteration
< 3; ++testIteration
) {
39 // In all but the marquee case, we should opt into composited scrolling
40 // and should not repaint.
41 var expected_results
= [false, true, false];
42 var container
= document
.getElementById("container");
43 var marquee
= document
.getElementById("marquee");
44 var span
= document
.getElementById("span");
46 var toScroll
= container
;
47 if (testIteration
== 0) {
48 var selection
= getSelection();
50 var range
= document
.createRange();
51 range
.selectNode(document
.getElementById("selection-start"));
52 selection
.addRange(range
);
54 range
= document
.createRange();
55 range
.selectNode(document
.getElementById("selection-end"));
56 selection
.addRange(range
);
57 } else if (testIteration
== 1) {
58 marquee
.style
.display
= "block";
61 span
.style
.display
= "inline";
64 document
.body
.offsetTop
;
67 window
.internals
.startTrackingRepaints(document
);
69 toScroll
.scrollTop
= 100;
71 if (window
.internals
) {
72 if (hasScrollbarRepaint(window
.internals
.layerTreeAsText(document
, internals
.LAYER_TREE_INCLUDES_REPAINT_RECTS
)) == expected_results
[testIteration
])
73 result
+= "PASS repainted when expected\n";
75 result
+= "FAIL did not repaint when expected\n";
76 window
.internals
.stopTrackingRepaints(document
);
79 // Do all cleanup here (so as not to affect repaint rects).
80 toScroll
.scrollTop
= 0;
81 span
.style
.display
= "none";
82 marquee
.style
.display
= "none";
83 getSelection().removeAllRanges();
89 function testNoRepaint() {
91 var container
= document
.getElementById("container");
93 document
.body
.offsetTop
;
96 window
.internals
.startTrackingRepaints(document
);
98 container
.scrollTop
= 100;
100 if (window
.internals
) {
101 if (!hasScrollbarRepaint(window
.internals
.layerTreeAsText(document
, internals
.LAYER_TREE_INCLUDES_REPAINT_RECTS
)))
102 result
+= "PASS did not repaint as expected\n";
104 result
+= "FAIL repainted when unexpected\n";
105 window
.internals
.stopTrackingRepaints(document
);
108 container
.scrollTop
= 0;
113 function testOverflowHidden() {
115 var container
= document
.getElementById("container");
117 container
.style
.overflow
= "hidden";
118 document
.body
.offsetTop
;
120 if (window
.internals
)
121 window
.internals
.startTrackingRepaints(document
);
123 container
.scrollTop
= 100;
125 if (window
.internals
) {
126 if (hasScrollbarRepaint(window
.internals
.layerTreeAsText(document
, internals
.LAYER_TREE_INCLUDES_REPAINT_RECTS
)))
127 result
+= "PASS repainted when expected\n";
129 result
+= "FAIL did not repaint when expected\n";
131 window
.internals
.stopTrackingRepaints(document
);
134 container
.scrollTop
= 0;
140 var marquee
= document
.getElementById("marquee");
142 var result
= testRepaint();
143 result
+= testNoRepaint();
144 result
+= testOverflowHidden();
145 var pre
= document
.createElement('pre');
146 document
.body
.appendChild(pre
);
147 pre
.innerHTML
= result
;
148 if (!window
.internals
)
149 document
.getElementById("description").style
.display
= "block";
152 window
.onload
= doTests
;
155 #target::selection { background-color: green; }
160 border:
1px black solid;
162 -webkit-backface-visibility: hidden;
172 background-color: blue;
173 -webkit-backface-visibility: hidden;
181 background-color: green;
182 -webkit-backface-visibility: hidden;
196 -webkit-backface-visibility: hidden;
202 <pre id=
"description">
203 This test ensures that if the only thing that scrolls is a composited layer,
204 we do not repaint. It passes if we repaint when we have to draw the selection
205 block gaps or if we have content that is not in a composited layer. It also
206 checks that we do not repaint when all the content is in a composited layer.
209 <span id=
"span">Hello!
</span>
210 <div id=
"fixed"></div>
211 <div class=
"scrolled" id=
"selection-start"></div>
212 <div class=
"scrolled" id=
"selection-end"></div>
213 <div class=
"scrolled"></div>
214 <div class=
"scrolled"></div>
215 <div class=
"scrolled"></div>
216 <div class=
"scrolled"></div>
217 <div class=
"scrolled"></div>
218 <div class=
"scrolled"></div>
219 <div class=
"scrolled"></div>
221 <marquee id=
"marquee" direction=
"up" scrollamount=
"1">
222 <p>Lorem ipsum dolor amet
</p>
223 <p>Lorem ipsum dolor amet
</p>
224 <p>Lorem ipsum dolor amet
</p>
225 <p>Lorem ipsum dolor amet
</p>
226 <p>Lorem ipsum dolor amet
</p>
227 <p>Lorem ipsum dolor amet
</p>
228 <p>Lorem ipsum dolor amet
</p>