4 <link rel=
"help" href=
"http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent">
5 <script src=
"../../resources/js-test.js"></script>
9 var expectedDeltaY
= scrollAmount
* -40;
14 testDiv
= document
.getElementById('target');
15 document
.addEventListener('wheel', wheelHandler
);
16 if (!window
.eventSender
) {
17 debug("FAIL: This test requires window.eventSender.");
21 debug('Test mousewheel events over scrollable div');
23 debug('With ctrl modifier set and canScroll set to be false');
25 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ 5, testDiv
.offsetTop
+ 5);
26 eventSender
.mouseScrollBy(0, scrollAmount
, false, true, "ctrlKey", false);
27 shouldBe("wheelEventCount", "1");
28 shouldEvaluateTo("deltaY", expectedDeltaY
);
29 shouldBeTrue("ctrlKey");
30 shouldBe("testDiv.scrollTop", "0");
32 debug('Without ctrl and canScroll set to be default true');
34 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ 5, testDiv
.offsetTop
+ 5);
35 eventSender
.mouseScrollBy(0, scrollAmount
, false, true);
36 shouldBe("wheelEventCount", "1");
37 shouldEvaluateTo("deltaY", expectedDeltaY
);
38 shouldBeFalse("ctrlKey");
39 shouldBe("testDiv.scrollTop", "deltaY");
42 debug('Test mousewheel events over the document');
43 testDiv
= document
.getElementById('target2');
45 debug('With ctrl modifier set and canScroll set to be false');
47 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ 5, testDiv
.offsetTop
+ 5);
48 eventSender
.mouseScrollBy(0, scrollAmount
, false, true, "ctrlKey", false);
49 shouldBe("wheelEventCount", "1");
50 shouldEvaluateTo("deltaY", expectedDeltaY
);
51 shouldBeTrue("ctrlKey");
52 shouldBe("window.scrollY", "0");
54 debug('With ctrl modifier set and canScroll set to be true');
56 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ 5, testDiv
.offsetTop
+ 5);
57 eventSender
.mouseScrollBy(0, scrollAmount
, false, true, "ctrlKey", true);
58 shouldBe("wheelEventCount", "1");
59 shouldEvaluateTo("deltaY", expectedDeltaY
);
60 shouldBeTrue("ctrlKey");
61 shouldBe("window.scrollY", "deltaY");
63 debug('Now without ctrl and canScroll set to be default true');
65 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ 5, testDiv
.offsetTop
+ 5);
66 eventSender
.mouseScrollBy(0, scrollAmount
, false, true);
67 shouldBe("wheelEventCount", "1");
68 shouldEvaluateTo("deltaY", expectedDeltaY
);
69 shouldBeFalse("ctrlKey");
70 shouldEvaluateTo("window.scrollY", 2 * expectedDeltaY
);
73 var wheelEventCount
= 0;
75 function wheelHandler(e
) {
85 <div id=
"target" style=
"border:solid 1px green; width:220px; height:70px; overflow:scroll; white-space:nowrap;">
86 TOP
<br/><br/><br/><br/>
87 Scroll mouse wheel over here
<br/><br/><br/><br/>
90 <div id=
"target2" style=
"border:solid 1px blue;">
91 And scroll the document here
93 <div style=
"height: 2000px;"></div>
95 <div id=
"console"></div>
97 description("Tests that wheel events with the ctrl modifier are handled properly");