| 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..8807c5f77a7fd331a69ae9db19355111471857fe
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/events/mouse-event-buttons-attribute.html
|
| @@ -0,0 +1,133 @@
|
| +<!DOCTYPE html>
|
| +<div id="region" style="width:100px; height:100px;"></div>
|
| +<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
|
| +};
|
| +const ME = 'MouseEvent';
|
| +const WE = 'WheelEvent';
|
| +const GE = 'GestureEvent';
|
| +
|
| +var buttons = -2;
|
| +var div = document.getElementById('region');
|
| +var testSet = [
|
| + { type: ME, name: 'dblclick', modifiers: [L], action: doubleClickAction },
|
| + { type: ME, name: 'click', modifiers: [L, R], action: clickAction },
|
| + { type: ME, name: 'mousedown', modifiers: [L, M, R], action: clickAction },
|
| + { type: ME, name: 'mouseup', modifiers: [L, R], modifiersDown: [L, M, R], action: mouseUpAction },
|
| + { type: ME, name: 'mousemove', modifiers: [], action: moveAction },
|
| + { type: ME, name: 'mousemove', modifiers: [L], action: moveAction },
|
| + { type: ME, name: 'mouseenter', modifiers: [R, M], action: moveAction },
|
| + { type: ME, name: 'mouseleave', modifiers: [L, R], action: moveAction },
|
| + { type: ME, name: 'mouseover', modifiers: [L, M], action: moveAction },
|
| + { type: ME, name: 'mouseout', modifiers: [L], action: moveAction },
|
| + { type: ME, name: 'contextmenu', modifiers: [R], action: rightClickAction },
|
| + { type: WE, name: 'mousewheel', modifiers: [L, R], action: wheelAction },
|
| + { type: GE, name: 'dblclick', modifiers: [L], action: doubleTapAction },
|
| + { type: GE, name: 'click', modifiers: [L], action: tapAction },
|
| + { type: GE, name: 'mousedown', modifiers: [L], action: tapAction },
|
| + { type: GE, name: 'mouseup', modifiers: [], modifiersDown: [L], action: tapAction },
|
| + { type: GE, name: 'mousemove', modifiers: [], action: tapAction },
|
| + { type: GE, name: 'contextmenu', modifiers: [R], action: longTapAction },
|
| +];
|
| +
|
| +function eventHandler(e)
|
| +{
|
| + buttons = e.buttons;
|
| +}
|
| +
|
| +function moveAction(modifiers)
|
| +{
|
| + eventSender.mouseMoveTo(-1, -1, modifiers);
|
| + eventSender.mouseMoveTo(50, 50, modifiers);
|
| +}
|
| +
|
| +function clickAction(modifiers)
|
| +{
|
| + moveAction(modifiers);
|
| + eventSender.mouseDown(0, modifiers);
|
| + eventSender.mouseUp(0, modifiers);
|
| +}
|
| +
|
| +function rightClickAction(modifiers)
|
| +{
|
| + moveAction(modifiers);
|
| + eventSender.mouseDown(2, modifiers);
|
| + eventSender.mouseUp(2, modifiers);
|
| +}
|
| +
|
| +function doubleClickAction(modifiers)
|
| +{
|
| + clickAction(modifiers);
|
| + clickAction(modifiers);
|
| +}
|
| +
|
| +function mouseUpAction(modifiers, modifiersDown)
|
| +{
|
| + moveAction(modifiersDown);
|
| + eventSender.mouseDown(0, modifiersDown);
|
| + eventSender.mouseUp(1, modifiers);
|
| +}
|
| +
|
| +function wheelAction(modifiers)
|
| +{
|
| + moveAction(modifiers);
|
| + eventSender.mouseScrollBy(0, 120, false, true, modifiers);
|
| +}
|
| +
|
| +function tapAction(modifiers)
|
| +{
|
| + eventSender.gestureTap(50, 50);
|
| +}
|
| +
|
| +function longTapAction(modifiers)
|
| +{
|
| + eventSender.gestureLongPress(50, 50);
|
| +}
|
| +
|
| +function doubleTapAction(modifiers)
|
| +{
|
| + eventSender.gestureTap(50, 50, 2);
|
| +}
|
| +
|
| +function raiseEvent(n)
|
| +{
|
| + if (!window.eventSender)
|
| + return;
|
| +
|
| + div.addEventListener(testSet[n].name, eventHandler, false);
|
| + testSet[n].action(testSet[n].modifiers, testSet[n].modifiersDown);
|
| + testSet[n].buttons = buttons;
|
| + div.removeEventListener(testSet[n].name, eventHandler, false);
|
| + buttons = -1;
|
| +}
|
| +
|
| +function expectedValue(modifiers)
|
| +{
|
| + var value = 0;
|
| + for (var i = 0; i < modifiers.length; i++)
|
| + value |= TABLE[modifiers[i]];
|
| +
|
| + return value;
|
| +}
|
| +
|
| +for (var i = 0; i < testSet.length; i++)
|
| + raiseEvent(i);
|
| +
|
| +for (var i = 0; i < testSet.length; i++) {
|
| + var modifiersDown = '';
|
| + if (testSet[i].modifiersDown != undefined)
|
| + modifiersDown += '[' + testSet[i].modifiersDown + '] -> ';
|
| + debug(testSet[i].type + '::' + testSet[i].name + ' test ' + modifiersDown + '[' + testSet[i].modifiers + ']');
|
| + shouldBeEqualToNumber('testSet[i].buttons', expectedValue(testSet[i].modifiers));
|
| + debug('');
|
| +}
|
| +
|
| +</script>
|
|
|