20 border:
2px solid black;
25 background-color: blue;
43 background-color: purple;
51 background-color: green;
61 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(true);
63 function addDomElement(elementType
, className
, id
, parent
, description
, indent
)
65 var element
= document
.createElement(elementType
);
66 element
.setAttribute("class", className
);
67 element
.setAttribute("id", id
);
68 if (parent
=== "body")
69 document
.body
.appendChild(element
);
71 document
.getElementById(parent
).appendChild(element
);
73 if (elementType
=== "div") {
74 for (var i
= 0; i
< indent
; ++i
)
75 description
.push(" ");
76 description
.push("+ ");
79 description
.push(", class: ");
80 description
.push(className
);
82 description
.push("\n");
88 function positionElement(id
, left
, top
) {
89 var element
= document
.getElementById(id
);
90 element
.style
.left
= left
+ "px";
91 element
.style
.top
= top
+ "px";
94 function buildDom(description
, indent
, parameters
)
96 var configurationElement
= parameters
.title
;
97 var containerElement
= "container-" + parameters
.title
;
98 var ancestorElement
= "ancestor-" + parameters
.title
;
99 var parentElement
= configurationElement
;
101 addDomElement("div", "positionAbsolute", configurationElement
, "body", description
, indent
);
102 positionElement(configurationElement
, parameters
.left
, parameters
.top
);
103 if (parameters
.hasSibling
) {
104 addDomElement("div", "", ancestorElement
, parentElement
, description
, indent
);
106 var siblingElement
= "sibling-" + parameters
.title
;
107 addDomElement("div", "positionFixed sibling", siblingElement
, ancestorElement
, description
, indent
);
108 positionElement(siblingElement
, parameters
.left
+ 5, parameters
.top
+ 10);
109 parentElement
= ancestorElement
;
112 var overflowClass
= parameters
.isContainingBlock
113 ? "positionAbsolute overflow"
116 addDomElement("div", overflowClass
, containerElement
, parentElement
, description
, indent
);
119 parentElement
= containerElement
;
120 if (parameters
.hasGrandchildren
) {
121 var scrollingContainerElement
= "scrollingContainer-" + parameters
.title
;
122 addDomElement("div", "", scrollingContainerElement
, parentElement
, description
, indent
);
124 parentElement
= scrollingContainerElement
;
127 var positionedClass
= parameters
.isFixedPositioned
129 : "positionAbsolute";
131 var positionedElement
= "positioned-" + parameters
.title
;
132 addDomElement("div", positionedClass
+ " positioned", positionedElement
, parentElement
, description
, indent
);
133 if (parameters
.isFixedPositioned
)
134 positionElement(positionedElement
, parameters
.left
+ 25, parameters
.top
+ 65);
136 for (var i
= 0; i
< 5; ++i
) {
137 var scrolledClass
= "scrolled";
139 scrolledClass
+= " onTop";
140 addDomElement("div", scrolledClass
, "scrolled-" + parameters
.title
, parentElement
, description
, indent
);
144 function testConfiguration(configuration
, index
, description
) {
145 description
.push("\n" + (index
+ 1) + ". '" + configuration
.title
+ "'\n");
146 var configurationsPerRow
= 4;
147 configuration
.top
= 10 + 120 * (Math
.floor(index
/ configurationsPerRow
));
148 configuration
.left
= 10 + 120 * (index
% configurationsPerRow
);
149 buildDom(description
, 0, configuration
);
153 if (window
.internals
)
154 testRunner
.dumpAsTextWithPixelResults();
156 // Some configurations are as not meaningful for fixed-pos. For example, we
157 // alternate between having the scroll container be a containing block for
158 // the positioned descendant. For the fixed-pos case, the containing block
159 // will be the viewport.
160 var configurations
= [
162 'title': 'absolute-grandchildren-not-contained',
163 'isFixedPositioned': false,
164 'isContainingBlock': false,
166 'hasGrandchildren': true,
169 'title': 'absolute-grandchildren',
170 'isFixedPositioned': false,
171 'isContainingBlock': true,
173 'hasGrandchildren': true,
176 'title': 'absolute-not-contained',
177 'isFixedPositioned': false,
178 'isContainingBlock': false,
180 'hasGrandchildren': false,
183 'title': 'absolute-sibling-grandchildren-not-contained',
184 'isFixedPositioned': false,
185 'isContainingBlock': false,
187 'hasGrandchildren': true,
190 'title': 'absolute-sibling-grandchildren',
191 'isFixedPositioned': false,
192 'isContainingBlock': true,
194 'hasGrandchildren': true,
197 'title': 'absolute-sibling-not-contained',
198 'isFixedPositioned': false,
199 'isContainingBlock': false,
201 'hasGrandchildren': false,
204 'title': 'absolute-sibling',
205 'isFixedPositioned': false,
206 'isContainingBlock': true,
208 'hasGrandchildren': false,
212 'isFixedPositioned': false,
213 'isContainingBlock': true,
215 'hasGrandchildren': false,
218 'title': 'fixed-sibling-grandchildren',
219 'isFixedPositioned': true,
220 'isContainingBlock': true,
222 'hasGrandchildren': true,
225 'title': 'fixed-sibling',
226 'isFixedPositioned': true,
227 'isContainingBlock': true,
229 'hasGrandchildren': false,
232 'title': 'fixed-grandchildren',
233 'isFixedPositioned': true,
234 'isContainingBlock': true,
236 'hasGrandchildren': true,
240 'isFixedPositioned': true,
241 'isContainingBlock': true,
243 'hasGrandchildren': false,
247 var description
= [ "We check that scrolling is accelerated in the following configurations:\n" ];
248 for (var i
= 0; i
< configurations
.length
; ++i
)
249 testConfiguration(configurations
[i
], i
, description
);
251 var containers
= document
.getElementsByClassName("overflow");
252 for (var i
= 0; i
< containers
.length
; ++i
) {
253 var container
= containers
[i
];
254 container
.scrollTop
= container
.scrollHeight
- container
.clientHeight
;
257 addDomElement("pre", "", "console", "body", [], 0);
258 var pre
= document
.getElementById("console");
260 if (window
.internals
) {
261 var layerTreeAsText
= internals
.layerTreeAsText(document
);
262 pre
.style
.left
= "-80000px";
263 pre
.innerHTML
= layerTreeAsText
;
265 pre
.innerHTML
= description
.join("");
269 window
.onload
= doTest
;