Chromium Code Reviews| Index: LayoutTests/fast/events/mouse-event-buttons-attribute.html |
| diff --git a/LayoutTests/fast/events/mouse-event-buttons-attribute.html b/LayoutTests/fast/events/mouse-event-buttons-attribute.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c935008b2618a9300a633fc7ac077896968381c0 |
| --- /dev/null |
| +++ b/LayoutTests/fast/events/mouse-event-buttons-attribute.html |
| @@ -0,0 +1,140 @@ |
| +<!DOCTYPE html> |
| +<body> |
|
Rick Byers
2014/11/18 20:29:19
nit: remove <body> tag - see http://www.chromium.o
zino
2014/11/24 13:07:08
Done.
|
| +<script src="../../resources/js-test.js"></script> |
| +<script> |
| + |
| +const L = 'leftButton'; |
| +const R = 'rightButton'; |
| +const M = 'middleButton'; |
| +const TABLE = { |
| + 'leftButton': 1, |
| + 'rightButton': 2, |
| + 'middleButton': 4 |
| +}; |
| + |
| +function mouseEvent() |
| +{ |
| + if (window.eventSender) |
| + window.buttons = event.buttons; |
|
Rick Byers
2014/11/18 20:29:18
relying on the global 'event' object is discourage
zino
2014/11/24 13:07:07
Done.
|
| +} |
| + |
| +function mouseTest(eventName, modifiers, mouseAction) |
| +{ |
| + testEvent(eventName, modifiers, mouseAction, "MouseEvent"); |
| +} |
| + |
| +function gestureTest(eventName, modifiers, mouseAction) |
| +{ |
| + testEvent(eventName, modifiers, mouseAction, "GestureEvent"); |
| +} |
| + |
| +function wheelTest(eventName, modifiers, mouseAction) |
| +{ |
| + testEvent(eventName, modifiers, mouseAction, "WheelEvent"); |
| +} |
| + |
|
Rick Byers
2014/11/18 20:29:19
add 'var buttons' to make it clear you're creating
zino
2014/11/24 13:07:08
Done.
|
| +function testEvent(eventName, modifiers, mouseAction, description) |
| +{ |
| + if (!window.eventSender) |
| + return; |
| + |
| + var div = document.createElement('div'); |
| + div.style.width = '100px'; |
| + div.style.height = '100px'; |
| + document.body.insertBefore(div, document.body.firstChild); |
|
Rick Byers
2014/11/18 20:29:18
Is there a reason you want to create a new div for
zino
2014/11/24 13:07:07
Done.
I'm not sure but shouldXXXX series in test.
Rick Byers
2014/11/25 17:44:27
Perhaps what you were seeing was that the console
zino
2014/11/28 12:29:28
Done.
|
| + |
|
Rick Byers
2014/11/18 20:29:19
You should probably verify that your event handler
zino
2014/11/24 13:07:08
Done.
|
| + div.addEventListener(eventName, mouseEvent, false); |
| + mouseAction(modifiers); |
| + div.removeEventListener(eventName, mouseEvent, false); |
| + |
| + var expectedValue = 0; |
| + for (var i = 0; i < modifiers.length; i++) |
| + expectedValue |= TABLE[modifiers[i]] |
| + |
| + debug(description + '::' + eventName + ' test [' + modifiers + ']'); |
| + shouldBe('buttons', expectedValue.toString()); |
|
Rick Byers
2014/11/18 20:29:19
why toString? Maybe use shouldBeEqualToNumber ins
zino
2014/11/24 13:07:08
Done.
Oh, I didn't know that.
|
| + debug(''); |
| + |
| + window.buttons = 0; |
| + eventSender.mouseMoveTo(-1, -1); |
| + eventSender.mouseUp(); |
| +} |
| + |
| +mouseTest('click', [L, R], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseDown(0, modifiers); |
| + eventSender.mouseUp(0, modifiers); |
| +}); |
| + |
| +mouseTest('dblclick', [L, M], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50); |
| + eventSender.mouseDown(0, modifiers); |
| + eventSender.mouseUp(0, modifiers); |
| + eventSender.mouseDown(0, modifiers); |
| + eventSender.mouseUp(0, modifiers); |
| +}); |
| + |
| +mouseTest('mousedown', [L, M, R], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseDown(0, modifiers); |
| + eventSender.mouseUp(0, modifiers); |
| +}); |
| + |
| +mouseTest('mouseup', [R], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseDown(0, modifiers); |
| + eventSender.mouseUp(0, modifiers); |
| +}); |
| + |
| +mouseTest('mousemove', [L], function(modifiers) { |
|
Rick Byers
2014/11/18 20:29:19
you should have one test where there are no modifi
zino
2014/11/24 13:07:08
Done.
|
| + eventSender.mouseMoveTo(-1, -1, modifiers); |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| +}); |
| + |
| +mouseTest('mouseenter', [R, M], function(modifiers) { |
| + eventSender.mouseMoveTo(-1, -1, modifiers); |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| +}); |
| + |
| +mouseTest('mouseleave', [L, R], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseMoveTo(-1, -1, modifiers); |
| +}); |
| + |
| +mouseTest('mouseover', [L, M], function(modifiers) { |
| + eventSender.mouseMoveTo(-1, -1, modifiers); |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| +}); |
| + |
| +mouseTest('mouseout', [L], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseMoveTo(-1, -1, modifiers); |
| +}); |
| + |
| +wheelTest('mousewheel', [L, R], function(modifiers) { |
| + eventSender.mouseMoveTo(50, 50, modifiers); |
| + eventSender.mouseScrollBy(0, 120, false, true, modifiers); |
| +}); |
| + |
| +gestureTest('mousedown', [L], function() { |
| + eventSender.gestureTap(50, 50); |
| +}); |
| + |
| +gestureTest('mouseup', [L], function() { |
| + eventSender.gestureTap(50, 50); |
| +}); |
| + |
| +gestureTest('click', [L], function() { |
| + eventSender.gestureTap(50, 50); |
| +}); |
| + |
| +gestureTest('dblclick', [L], function() { |
| + eventSender.gestureTap(50, 50, 2); |
| +}); |
| + |
| +gestureTest('mousemove', [L], function() { |
| + eventSender.gestureTap(50, 50); |
| +}); |
| + |
| +</script> |
| +</body> |