Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / relative-offset-of-simulated-click.html
blob8f60afe6df15638446c35e06282be6b325c064cb
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <script>
9 description("This test documents the behavior of MouseEvent.offsetX/Y in response to HTMLElement.click().");
11 var testDiv = document.createElement("div");
12 testDiv.setAttribute("style", "background: green; width: 100px; height: 100px; position: absolute; top: 100px; left: 100px;");
13 document.body.appendChild(testDiv);
15 testDiv.addEventListener("click", function(e) {
16 event = e;
17 shouldBe("event.offsetX", expectedX);
18 shouldBe("event.offsetY", expectedY);
19 });
21 debug("Simulated click with .click():");
22 expectedX = "0";
23 expectedY = "0";
24 testDiv.click();
26 if (!window.eventSender)
27 debug("This part of the test requires eventSender!");
28 else {
29 debug("Click with mouse at 0,0:");
30 expectedX = "0";
31 expectedY = "0";
32 eventSender.mouseMoveTo(100, 100);
33 eventSender.mouseDown();
34 eventSender.mouseUp();
36 debug("Click with mouse at 40,50:");
37 expectedX = "40";
38 expectedY = "50";
39 eventSender.mouseMoveTo(140, 150);
40 eventSender.mouseDown();
41 eventSender.mouseUp();
44 testDiv.remove();
46 </script>
47 </body>
48 </html>