Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: LayoutTests/fast/events/wheelevent-basic.html

Issue 23034006: WheelEvent's deltaX/deltaY should report real amount of pixels scrolled (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo in test Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEven t"> 4 <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEven t">
5 <script src="../js/resources/js-test-pre.js"></script> 5 <script src="../js/resources/js-test-pre.js"></script>
6 <script> 6 <script>
7 var deltaX = 10; 7 var deltaX = 0;
8 var deltaY = 120; 8 var deltaY = 0;
9 var expectedDeltaX;
10 var expectedDeltaY;
9 11
10 var testDiv; 12 var testDiv;
11 function runTest() { 13 function runTest() {
12 // Basic checks. 14 // Basic checks.
13 shouldBe('WheelEvent.__proto__', 'MouseEvent'); 15 shouldBe('WheelEvent.__proto__', 'MouseEvent');
14 shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype'); 16 shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype');
15 shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00'); 17 shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00');
16 shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01'); 18 shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01');
17 shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02'); 19 shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02');
18 20
19 testDiv = document.getElementById('target'); 21 testDiv = document.getElementById('target');
20 shouldBeNull('window.onwheel'); 22 shouldBeNull('window.onwheel');
21 shouldBeNull('document.onwheel'); 23 shouldBeNull('document.onwheel');
22 shouldBeNull('testDiv.onwheel'); 24 shouldBeNull('testDiv.onwheel');
23 testDiv.addEventListener('wheel', wheelHandler); 25 testDiv.addEventListener('wheel', wheelHandler);
24 if (window.eventSender) { 26 if (window.eventSender) {
25 eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5); 27 eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
26 eventSender.mouseScrollBy(deltaX, deltaY); 28 eventSender.mouseScrollBy(-1, -2);
29 expectedDeltaX = testDiv.scrollLeft;
30 expectedDeltaY = testDiv.scrollTop;
31 shouldBeTrue("deltaX > 0");
32 shouldBe("deltaX", "expectedDeltaX");
33 shouldBeTrue("deltaY > 0");
34 shouldBe("deltaY", "expectedDeltaY");
27 } else { 35 } else {
28 debug("FAIL: This test requires window.eventSender."); 36 debug("FAIL: This test requires window.eventSender.");
29 finishJSTest();
30 } 37 }
31 } 38 }
32 39
33 var testEvent; 40 var testEvent;
34 var tickMultiplier = 120;
35 var expectedDeltaX = -deltaX * tickMultiplier;
36 var expectedDeltaY = -deltaY * tickMultiplier;
37 function wheelHandler(e) { 41 function wheelHandler(e) {
38 testEvent = e; 42 testEvent = e;
39 shouldBe("testEvent.__proto__", "WheelEvent.prototype"); 43 shouldBe("testEvent.__proto__", "WheelEvent.prototype");
40 shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype"); 44 shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype");
41 shouldBe("testEvent.deltaX", "expectedDeltaX"); 45 if (e.deltaX)
42 shouldBe("testEvent.deltaY", "expectedDeltaY"); 46 deltaX = e.deltaX;
47 if (e.deltaY)
48 deltaY = e.deltaY;
43 shouldBe("testEvent.deltaZ", "0"); 49 shouldBe("testEvent.deltaZ", "0");
44 shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL") 50 shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL")
45
46 testDiv.removeEventListener("wheel", wheelHandler);
47 finishJSTest();
48 } 51 }
49 52
50 </script> 53 </script>
51 </head> 54 </head>
52 <body> 55 <body>
53 <span id="parent"> 56 <span id="parent">
54 <div id="target" style="border:solid 1px green; width:220px; height:70px; ov erflow:scroll"> 57 <div id="target" style="border:solid 1px green; width:220px; height:70px; ov erflow-x:scroll; overflow-y:scroll; white-space: nowrap;">
arv (Not doing code reviews) 2013/08/22 14:15:49 "overflow: scroll" is shorthand for "overflow-x: s
do-not-use 2013/08/22 14:46:03 Oh, I did not know that. I will fix it.
do-not-use 2013/08/22 15:08:21 Done.
55 TOP TOP TOP TOP TOP TOP TOP 58 TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/>
56 Scroll mouse wheel over here 59 Scroll mouse wheel over here<br/>
57 Scroll mouse wheel over here 60 Scroll mouse wheel over here<br/>
58 Scroll mouse wheel over here 61 Scroll mouse wheel over here<br/>
59 Scroll mouse wheel over here 62 Scroll mouse wheel over here<br/>
60 Scroll mouse wheel over here 63 Scroll mouse wheel over here<br/>
61 Scroll mouse wheel over here 64 Scroll mouse wheel over here<br/>
62 END END END END END END END 65 END END END END END END END END END END END END END END<br/>
63 </div> 66 </div>
64 </span> 67 </span>
68 <div id="console"></div>
65 <script> 69 <script>
66 description("Tests the basic functionality of the standard wheel event"); 70 description("Tests the basic functionality of the standard wheel event");
67 window.jsTestIsAsync = true;
68 71
69 runTest(); 72 runTest();
70 </script> 73 </script>
71 <script src="../js/resources/js-test-post.js"></script> 74 <script src="../js/resources/js-test-post.js"></script>
72 </body> 75 </body>
73 </html> 76 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/wheelevent-basic-expected.txt » ('j') | Source/core/dom/WheelEvent.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698