Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-xy-properties.html
bloba6108181016a28181d7a574422b272e283f8bcf4
1 <head>
2 <script src="../../../resources/js-test.js"></script>
3 <script>
4 var nrmouseclicks = 0; // small hack to distinguish between clicks
5 var ev;
6 function mouseev(event) {
7 if (nrmouseclicks == 0) {
8 shouldBe("event.clientX", "50");
9 shouldBe("event.clientY", "50");
10 shouldBe("event.pageX", "50");
11 shouldBe("event.pageY", "50");
12 shouldBe("event.layerX", "50");
13 shouldBe("event.layerY", "50");
14 shouldBe("event.offsetX", "42");
15 shouldBe("event.offsetY", "42");
16 nrmouseclicks++;
17 } else if (nrmouseclicks == 1) {
18 shouldBe("event.clientX", "50");
19 shouldBe("event.clientY", "50");
20 shouldBe("event.pageX", "50");
21 shouldBe("event.pageY", "550");
22 shouldBe("event.layerX", "50");
23 shouldBe("event.layerY", "550");
24 shouldBe("event.offsetX", "42");
25 shouldBe("event.offsetY", "542");
26 nrmouseclicks++;
27 } else if (nrmouseclicks == 2) {
28 shouldBe("event.clientX", "50");
29 shouldBe("event.clientY", "50");
30 shouldBe("event.pageX", "550");
31 shouldBe("event.pageY", "50");
32 shouldBe("event.layerX", "550");
33 shouldBe("event.layerY", "50");
34 shouldBe("event.offsetX", "542");
35 shouldBe("event.offsetY", "42");
36 nrmouseclicks++;
38 // test initMouseEvent
39 window.scrollTo(500, 500);
40 ev = document.createEvent("MouseEvent");
41 ev.initMouseEvent("mousedown", true, true, document.defaultView, 1, 50, 50, 50, 50, false, false, false, false, 0, document);
42 var child = document.getElementById('target');
43 child.dispatchEvent(ev);
44 } else {
45 shouldBe("ev.clientX", "50");
46 shouldBe("ev.clientY", "50");
47 shouldBe("ev.pageX", "550");
48 shouldBe("ev.pageY", "550");
49 shouldBe("ev.layerX", "550");
50 shouldBe("ev.layerY", "550");
51 shouldBe("ev.offsetX", "542");
52 shouldBe("ev.offsetY", "542");
55 function test() {
56 if (window.testRunner) {
57 testRunner.dumpAsText();
58 // test a normal mouse to
59 eventSender.mouseMoveTo(50, 50);
60 eventSender.mouseDown();
61 eventSender.mouseUp();
63 // now scroll a bit down and verify that clientY does not change
64 window.scrollTo(0, 500);
65 eventSender.mouseDown();
66 eventSender.mouseUp();
68 // now scroll a bit to the right and verify that clientX does not change
69 window.scrollTo(500, 0);
70 eventSender.mouseDown();
71 eventSender.mouseUp();
74 </script>
75 </head>
76 <body onload="test()">
77 <div id="target" style="background: red; width:2000px; height: 2000px" onmousedown="mouseev(event)">
78 </div>
79 <div id="console"></div>
80 </body>