blob: 025cf76cf1011874468723e43a7b19e97ab9e462 [file] [log] [blame]
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +00001<!DOCTYPE html>
2<html>
3<head>
4<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent">
mark.lam@apple.com436bf822013-09-07 23:07:25 +00005<script src="../../resources/js-test-pre.js"></script>
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +00006<script>
ap@apple.com8c45cee2015-08-21 23:09:54 +00007var eventDeltaX = 0;
8var eventDeltaY = 0;
9var scrollDeltaX;
10var scrollDeltaY;
11
12jsTestIsAsync = true;
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000013
14var testDiv;
15function runTest() {
16 // Basic checks.
17 shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype');
18 shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00');
19 shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01');
20 shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02');
21
22 testDiv = document.getElementById('target');
23 shouldBeNull('window.onwheel');
24 shouldBeNull('document.onwheel');
25 shouldBeNull('testDiv.onwheel');
26 testDiv.addEventListener('wheel', wheelHandler);
27 if (window.eventSender) {
28 eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
29 eventSender.mouseScrollBy(-1, -2);
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000030 } else {
31 debug("FAIL: This test requires window.eventSender.");
32 }
33}
34
35var testEvent;
36function wheelHandler(e) {
ap@apple.com8c45cee2015-08-21 23:09:54 +000037 debug("Wheel event fired");
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000038 testEvent = e;
39 shouldBe("testEvent.__proto__", "WheelEvent.prototype");
40 shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype");
ap@apple.com8c45cee2015-08-21 23:09:54 +000041 shouldBeTrue("testEvent.deltaX > 0");
42 shouldBeTrue("testEvent.deltaY > 0");
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000043 shouldBe("testEvent.deltaZ", "0");
44 shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL")
ap@apple.com8c45cee2015-08-21 23:09:54 +000045 eventDeltaX = e.deltaX;
46 eventDeltaY = e.deltaY;
47}
48
49function scrollHandler()
50{
51 debug("Scroll event fired");
52 scrollDeltaX = testDiv.scrollLeft;
53 scrollDeltaY = testDiv.scrollTop;
54 shouldBe("eventDeltaX", "scrollDeltaX");
55 shouldBe("eventDeltaY", "scrollDeltaY");
56
57 finishJSTest();
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000058}
59
60</script>
61</head>
62<body>
63<span id="parent">
ap@apple.com8c45cee2015-08-21 23:09:54 +000064 <div id="target" style="border:solid 1px green; width:100px; height:70px; overflow:scroll; white-space:nowrap;" onscroll="scrollHandler()">
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000065 TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/>
66 Scroll mouse wheel over here<br/>
67 Scroll mouse wheel over here<br/>
68 Scroll mouse wheel over here<br/>
69 Scroll mouse wheel over here<br/>
70 Scroll mouse wheel over here<br/>
71 Scroll mouse wheel over here<br/>
72 END END END END END END END END END END END END END END<br/>
73 </div>
74</span>
75<div id="console"></div>
76<script>
77description("Tests the basic functionality of the standard wheel event");
78
79runTest();
80</script>
mark.lam@apple.com436bf822013-09-07 23:07:25 +000081<script src="../../resources/js-test-post.js"></script>
ch.dumez@sisa.samsung.com181483e2013-08-27 10:09:06 +000082</body>
83</html>