11 background-color: red;
25 background-color: yellow;
33 background-color: blue;
41 background-color: green;
50 if (window.testRunner)
51 testRunner.dumpAsText();
53 if (window.internals) {
54 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnabled(true);
55 window.internals.settings.setCompositorDrivenAcceleratedScrollingEnabled(false);
58 function writeResult(iteration, expectedResult)
60 document.body.offsetTop;
62 if (!window.internals)
66 writeDebug(iteration);
68 var result = document.getElementById('result');
69 result.innerText += "iteration " + iteration + ": ";
71 var container = document.getElementById('container');
72 var containerOptedIn = window.internals.needsCompositedScrolling(container);
73 if (containerOptedIn === expectedResult)
74 result.innerText += "PASS, ";
76 result.innerText += "FAIL, ";
79 result.innerText += "container is composited.\n";
81 result.innerText += "container is not composited.\n";
84 function writeDebug(iteration)
86 var result = document.getElementById('result');
87 var content = document.getElementById('content');
88 var container = document.getElementById('container');
89 var contentPredecessor = document.getElementById('contentPredecessor');
90 var contentSuccessor = document.getElementById('contentSuccessor');
92 var elements = [container, contentPredecessor, content, contentSuccessor];
94 for (var i = 0; i < elements.length; i++) {
95 var element = elements[i];
96 var computedStyle = getComputedStyle(element);
98 result.innerText += "iteration " + iteration + ":\n";
99 result.innerText += "\telement: " + element.id + "\n";
100 result.innerText += "\theight: " + computedStyle.height + "\n";
101 result.innerText += "\twidth: " + computedStyle.width + "\n";
102 result.innerText += "\toverflowX: " + computedStyle.overflowX + "\n";
103 result.innerText += "\toverflowY: " + computedStyle.overflowY + "\n";
104 result.innerText += "\tdisplay: " + computedStyle.display + "\n";
105 result.innerText += "\tzIndex: " + computedStyle.zIndex + "\n";
109 function doSuccessorTest(test, testIndex)
111 container = document.getElementById('container');
112 contentSuccessor = document.getElementById('contentSuccessor');
114 content.style.width = test['width'];
115 content.style.height = test['height'];
116 container.style.overflowX = test['overflowX'];
117 container.style.overflowY = test['overflowY'];
118 contentSuccessor.style.display = test['display'];
120 var descendantCausesOverflow = test['width'] === '1000px' || test['height'] === '1000px' || test['display'] === 'block';
121 var containerScrolls = test['overflowX'] === 'scroll' || test['overflowY'] === 'scroll';
123 var shouldOptIn = descendantCausesOverflow && containerScrolls;
125 writeResult(testIndex, shouldOptIn);
128 function doPredecessorTest(test, testIndex)
130 container = document.getElementById('container');
131 contentPredecessor = document.getElementById('contentPredecessor');
133 contentPredecessor.style.display = test['display'];
134 container.style.zIndex = test['zIndex'];
136 var containerIsAStackingContext = test['zIndex'] === '1';
137 var predecessorIsInvisible = test['display'] === 'none';
139 // If the contentPredecessor is visible and the container is not a stacking
140 // context, then a non-descendant appears between our descendants; we
141 // fail the contiguity check and we should not opt in. If we are a
142 // stacking context or the predecessor is gone, we can opt in.
143 var shouldOptIn = containerIsAStackingContext || predecessorIsInvisible;
145 writeResult(testIndex, shouldOptIn);
150 var successorTests = [
151 { 'width': '1px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'none' },
152 { 'width': '1px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'block' },
153 { 'width': '1px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'none' },
154 { 'width': '1px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'block' },
155 { 'width': '1px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'none' },
156 { 'width': '1px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'block' },
157 { 'width': '1px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'none' },
158 { 'width': '1px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'block' },
159 { 'width': '1px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'none' },
160 { 'width': '1px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'block' },
161 { 'width': '1px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'none' },
162 { 'width': '1px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'block' },
163 { 'width': '1px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'none' },
164 { 'width': '1px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'block' },
165 { 'width': '1px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'none' },
166 { 'width': '1px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'block' },
167 { 'width': '1000px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'none' },
168 { 'width': '1000px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'block' },
169 { 'width': '1000px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'none' },
170 { 'width': '1000px', 'height': '1px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'block' },
171 { 'width': '1000px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'none' },
172 { 'width': '1000px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'block' },
173 { 'width': '1000px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'none' },
174 { 'width': '1000px', 'height': '1px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'block' },
175 { 'width': '1000px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'none' },
176 { 'width': '1000px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'visible', 'display': 'block' },
177 { 'width': '1000px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'none' },
178 { 'width': '1000px', 'height': '1000px', 'overflowX': 'visible', 'overflowY': 'scroll', 'display': 'block' },
179 { 'width': '1000px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'none' },
180 { 'width': '1000px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'visible', 'display': 'block' },
181 { 'width': '1000px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'none' },
182 { 'width': '1000px', 'height': '1000px', 'overflowX': 'scroll', 'overflowY': 'scroll', 'display': 'block' }
185 var predecessorTests = [
186 { 'display': 'block', 'zIndex': '1' },
187 { 'display': 'block', 'zIndex': 'auto' },
188 { 'display': 'none', 'zIndex': '1' },
189 { 'display': 'none', 'zIndex': 'auto' },
193 writeResult(testIndex++, false);
195 for (var i = 0; i < successorTests.length; i++)
196 doSuccessorTest(successorTests[i], testIndex++);
198 content.style.height = '1000px';
199 content.style.width = '1000px';
200 container.style.overflowX = 'scroll';
201 container.style.overflowY = 'scroll';
202 contentSuccessor.style.display = 'none';
203 predecessor.style.display = 'block';
205 writeResult(testIndex++, true);
207 for (var i = 0; i < predecessorTests.length; i++)
208 doPredecessorTest(predecessorTests[i], testIndex++);
211 window.addEventListener('load', runTests, false);
216 <div id="predecessor"></div>
218 <div id="contentPredecessor"></div>
219 <div id="content"></div>
220 <div id="contentSuccessor"></div>
222 <pre id="result"></pre>