3 testRunner.waitUntilDone();
7 var resultBox = document.getElementById('mousepos');
8 var offsets = 'element id: ' + e.target.id + '<br> clientX: ' + e.clientX + ' clientY: ' + e.clientY + '<br>';
9 offsets += 'offsetX: ' + e.offsetX + ' offsetY: ' + e.offsetY;
10 resultBox.innerHTML = offsets;
13 function dispatchEvent(clientX, clientY, expectedElementID, expectedOffsetX, expectedOffsetY)
15 var ev = document.createEvent("MouseEvent");
16 ev.initMouseEvent("click", true, true, window, 1, 1, 1, clientX, clientY, false, false, false, false, 0, document);
17 ev.expectedElement = expectedElementID;
18 ev.expectedOffsetX = expectedOffsetX;
19 ev.expectedOffsetY = expectedOffsetY;
20 var target = document.elementFromPoint(ev.pageX, ev.pageY);
21 target.dispatchEvent(ev);
24 function clicked(event)
26 var element = event.target;
29 if (element.id == event.expectedElement &&
30 event.offsetX == event.expectedOffsetX &&
31 event.offsetY == event.expectedOffsetY)
32 result = '<span style="color: green">PASS: event at (' + event.clientX + ', ' + event.clientY + ') hit ' + element.id + ' at offset (' + event.offsetX + ', ' + event.offsetY + ')</span>';
34 result = '<span style="color: red">FAIL: event at (' + event.clientX + ', ' + event.clientY + ') expected to hit ' + event.expectedElement + ' at (' + event.expectedOffsetX + ', ' + event.expectedOffsetY + ') but hit ' + element.id + ' at (' + event.offsetX + ', ' + event.offsetY + ')</span>';
41 var resultsDiv = document.getElementById('results');
42 resultsDiv.innerHTML += s + '<br>';
47 // In non-test mode, show the mouse coords for testing
48 if (window.testRunner)
49 document.getElementById('mousepos').style.display = 'none';
51 document.body.addEventListener('mousemove', mousemoved, false);
54 if (window.testRunner)
55 testRunner.notifyDone();
58 window.addEventListener('load', function() {
59 window.setTimeout(runTest, 0);