| <!DOCTYPE HTML> |
| <script src="../../../../resources/js-test.js"></script> |
| <style> |
| html, body { |
| margin: 0; |
| width: 2000px; |
| height: 2000px; |
| } |
| </style> |
| <div id=console></div> |
| <script> |
| var event; |
| var scrollOffset = { |
| x: 12, |
| y: 42 |
| }; |
| var point = { |
| x: 50, |
| y: 50 |
| }; |
| |
| var eventReceived = {}; |
| |
| function onEvent(e) { |
| debug("Received " + e.type + " in page"); |
| event = e; |
| eventReceived[e.type] = true; |
| shouldBe("event.screenX", "point.x"); |
| shouldBe("event.screenY", "point.y"); |
| shouldBe("event.clientX", "point.x"); |
| shouldBe("event.clientY", "point.y"); |
| shouldBe("event.pageX", "point.x + scrollOffset.x"); |
| shouldBe("event.pageY", "point.y + scrollOffset.y"); |
| } |
| |
| var eventTypes = ['mousemove', 'mousedown', 'mouseup', 'click']; |
| for (var i = 0; i < eventTypes.length; i++) |
| document.addEventListener(eventTypes[i],onEvent); |
| |
| description("Verifies that a tap occurring in a scrolled page has the correct co-ordinates"); |
| |
| if (window.eventSender) { |
| jsTestIsAsync = true; |
| window.onload = function() { |
| window.scrollTo(scrollOffset.x, scrollOffset.y); |
| |
| debug("Sending GestureTapDown to " + point.x + "," + point.y); |
| eventSender.gestureTapDown(point.x, point.y); |
| |
| debug("Sending GestureShowPress"); |
| eventSender.gestureShowPress(point.x, point.y); |
| |
| debug("Sending GestureTap"); |
| eventSender.gestureTap(point.x, point.y); |
| |
| shouldBeTrue("eventReceived.mousemove"); |
| shouldBeTrue("eventReceived.mousedown"); |
| shouldBeTrue("eventReceived.mouseup"); |
| shouldBeTrue("eventReceived.click"); |
| setTimeout(finishJSTest, 100); |
| } |
| } else { |
| debug("This test requires eventSender"); |
| } |
| </script> |