| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library wheel_event_test; | 5 library wheel_event_test; |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 | 9 |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 | 12 |
| 13 useHtmlConfiguration(); | 13 useHtmlConfiguration(); |
| 14 | 14 |
| 15 var userAgent = window.navigator.userAgent; | 15 var userAgent = window.navigator.userAgent; |
| 16 | 16 |
| 17 // Lame platform-dependent check to validate that our assumptions about | 17 // Lame platform-dependent check to validate that our assumptions about |
| 18 // which event is being used is correct. | 18 // which event is being used is correct. |
| 19 var wheelEvent = 'wheel'; | 19 var wheelEvent = 'wheel'; |
| 20 if (userAgent.contains("Opera", 0)) { | 20 if (userAgent.contains("Opera", 0)) { |
| 21 wheelEvent = 'mousewheel'; | 21 wheelEvent = 'mousewheel'; |
| 22 } else if (userAgent.contains("MSIE", 0)) { | 22 } else if (userAgent.contains("MSIE", 0)) { |
| 23 wheelEvent = 'mousewheel'; | 23 wheelEvent = 'mousewheel'; |
| 24 } else if (userAgent.contains('Firefox')) { | 24 } else if (userAgent.contains('Firefox')) { |
| 25 // FF appears to have recently added support for wheel. | 25 // FF appears to have recently added support for wheel. |
| 26 if (userAgent.contains('Firefox/17')) { | 26 wheelEvent = 'wheel'; |
| 27 wheelEvent = 'DOMMouseScroll'; | |
| 28 } else { | |
| 29 wheelEvent = 'wheel'; | |
| 30 } | |
| 31 } else if (userAgent.contains('WebKit', 0)) { | 27 } else if (userAgent.contains('WebKit', 0)) { |
| 32 wheelEvent = 'mousewheel'; | 28 wheelEvent = 'mousewheel'; |
| 33 } | 29 } |
| 34 | 30 |
| 35 test('wheelEvent', () { | 31 test('wheelEvent', () { |
| 36 var element = new DivElement(); | 32 var element = new DivElement(); |
| 37 element.on.mouseWheel.add(expectAsync1((e) { | 33 element.on.mouseWheel.add(expectAsync1((e) { |
| 38 expect(e.screenX, 100); | 34 expect(e.screenX, 100); |
| 39 expect(e.deltaX, 0); | 35 expect(e.deltaX, 0); |
| 40 expect(e.deltaY, 240); | 36 expect(e.deltaY, 240); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 240, | 61 240, |
| 66 0, | 62 0, |
| 67 100, | 63 100, |
| 68 200, | 64 200, |
| 69 10, | 65 10, |
| 70 20, | 66 20, |
| 71 0); | 67 0); |
| 72 element.$dom_dispatchEvent(event); | 68 element.$dom_dispatchEvent(event); |
| 73 }); | 69 }); |
| 74 } | 70 } |
| OLD | NEW |