4 <meta name=
"viewport" content=
"initial-scale=1, minimum-scale=1, maximum-scale=1">
14 cursor: crosshair; /* Debugging */
20 border:
10px solid gray;
30 background: lightGreen !important; /* Elements we click on are green */
69 border:
10px solid gray;
78 border:
1px solid black;
79 -webkit-column-count:
3;
95 transform: translate(
100px,
50px) rotate(
20deg);
99 overflow: hidden; /* No scrollbars */
105 border:
1px solid black;
136 This test is modeled after <LayoutTests/fast/events/offsetX-offsetY.html>,
137 but it is designed to not depend on inline text content to position the
138 targets on which we click.
141 <!-- Filler, to force scrolling -->
142 <div id=
"filler"></div>
144 <!-- Absolute, Relative, and Fixed position -->
145 <div id=
"absolute" class=
"box target">
146 <span style=
"position:absolute;left:0;top:0">Absolute
</span>
147 <div id=
"relative" class=
"box target">Relative
</div>
148 <div id=
"fixed" class=
"box target">Fixed
</div>
152 <table id=
"table" border=
"2" cellpadding=
"3" cellpadding=
"2">
153 <tr><th>x
</th><th>x
</th></tr>
155 <td><div id=
"table-content" class=
"line target">Table Content
</div></td>
157 <div class=
"line"></div><div class=
"line"></div>
158 <div class=
"line"></div><div class=
"line"></div>
159 <div class=
"line"></div><div class=
"line"></div>
166 <div class=
"column-line"></div><div class=
"column-line"></div>
167 <div class=
"column-line"></div><div class=
"column-line"></div>
168 <div class=
"column-line"></div><div class=
"column-line"></div>
169 <div class=
"column-line"></div><div class=
"column-line"></div>
170 <div class=
"column-line"></div><div class=
"column-line"></div>
171 <div class=
"column-line"></div><div class=
"column-line"></div>
172 <div id=
"in-columns" class=
"column-line target">In Columns
</div>
173 <div class=
"column-line"></div><div class=
"column-line"></div>
174 <div class=
"column-line"></div><div class=
"column-line"></div>
175 <div class=
"column-line"></div><div class=
"column-line"></div>
176 <div class=
"column-line"></div><div class=
"column-line"></div>
177 <div class=
"column-line"></div><div class=
"column-line"></div>
178 <div class=
"column-line"></div><div class=
"column-line"></div>
179 <div class=
"column-line"></div><div class=
"column-line"></div>
183 <div id=
"transformed" class=
"box target">Transformed
</div>
185 <!-- Overflowed Content -->
187 <div id=
"overflow-contents">
188 <div class=
"line"></div><div class=
"line"></div><div class=
"line"></div>
189 <div class=
"line"></div><div class=
"line"></div><div class=
"line"></div>
190 <div class=
"line"></div><div class=
"line"></div><div class=
"line"></div>
191 <div id=
"inside-overflow" class=
"target">In RTL overflow
</div>
192 <div class=
"line"></div><div class=
"line"></div><div class=
"line"></div>
197 <div id=
"results"></div>
198 <div id=
"mouse-position"></div>
202 if (!window
.testRunner
) {
203 document
.body
.onmousemove = function(e
) {
204 var resultBox
= document
.getElementById('mouse-position');
205 var offsets
= 'element id: ' + e
.target
.id
+ '<br> clientX: ' + e
.clientX
+ ' clientY: ' + e
.clientY
+ '<br>';
206 offsets
+= 'offsetX: ' + e
.offsetX
+ ' offsetY: ' + e
.offsetY
;
207 resultBox
.innerHTML
= offsets
;
212 var resultsDiv
= document
.getElementById('results');
213 resultsDiv
.innerHTML
+= s
+ '<br>';
216 function dispatchEvent(clientX
, clientY
, expectedElementID
, expectedOffsetX
, expectedOffsetY
) {
217 var e
= document
.createEvent("MouseEvent");
218 e
.initMouseEvent("click", true, true, window
, 1, 1, 1, clientX
, clientY
, false, false, false, false, 0, document
);
219 e
.expectedElementID
= expectedElementID
;
220 e
.expectedOffsetX
= expectedOffsetX
;
221 e
.expectedOffsetY
= expectedOffsetY
;
222 var target
= document
.elementFromPoint(e
.clientX
, e
.clientY
);
223 target
.dispatchEvent(e
);
226 function clicked(event
) {
227 var element
= event
.target
;
229 if (element
.id
=== event
.expectedElementID
&& event
.offsetX
=== event
.expectedOffsetX
&& event
.offsetY
=== event
.expectedOffsetY
) {
231 result
+= ' event at (' + event
.clientX
+ ', ' + event
.clientY
+ ')';
232 result
+= ' hit ' + element
.id
;
233 result
+= ' at offset (' + event
.offsetX
+ ', ' + event
.offsetY
+ ')';
236 result
+= ' event at (' + event
.clientX
+ ', ' + event
.clientY
+ ')';
237 result
+= ' expected to hit ' + event
.expectedElementID
;
238 result
+= ' at (' + event
.expectedOffsetX
+ ', ' + event
.expectedOffsetY
+ ')';
239 result
+= ' but hit ' + element
.id
+ ' at (' + event
.offsetX
+ ', ' + event
.offsetY
+ ')';
244 if (window
.testRunner
) {
245 window
.testRunner
.dumpAsText();
246 window
.testRunner
.waitUntilDone();
250 document
.body
.addEventListener('click', clicked
, false);
251 window
.addEventListener('load', function() {
252 setTimeout(function() {
253 // Scroll body and inner overflow box.
254 window
.scrollTo(20, 100);
255 var overflowContent
= document
.getElementById('overflow');
256 overflowContent
.scrollLeft
= 80;
257 overflowContent
.scrollTop
= 60;
258 setTimeout(function() {
260 dispatchEvent(109, 57, 'absolute', 29, 32);
261 dispatchEvent(161, 13, 'relative', 31, 28);
262 dispatchEvent(40, 297, 'table-content', 15, 18);
263 dispatchEvent(122, 407, 'transformed', 18, 15);
264 dispatchEvent(573, 480, 'inside-overflow', 2, 9);
265 dispatchEvent(707, 174, 'in-columns', 87, 13);
266 dispatchEvent(241, 67, 'fixed', 41, 17);
267 dispatchEvent(244, 102, 'fixed', 44, 52);
268 dispatchEvent(388, 88, 'fixed', 188, 38);
270 // End asynchronous test.
271 if (window
.testRunner
)
272 window
.testRunner
.notifyDone();