1 function dispatchWheelEvent(element, deltaX, deltaY)
3 var eventInit = { deltaX: -deltaX, deltaY: -deltaY };
4 var event = new WheelEvent('mousewheel', eventInit);
5 element.dispatchEvent(event);
9 function testWheelEvent(parameters)
11 var inputType = parameters['inputType'];
12 var initialValue = parameters['initialValue'];
13 var stepUpValue1 = parameters['stepUpValue1'];
14 var stepUpValue2 = parameters['stepUpValue2'];
15 description('Test for wheel operations for <input type=' + inputType + '>');
16 var parent = document.createElement('div');
17 document.body.appendChild(parent);
18 parent.innerHTML = '<input type=' + inputType + ' id=test value="' + initialValue + '"> <input id=another>';
19 input = document.getElementById('test');
22 debug('Initial value is ' + initialValue + '. We\'ll wheel up by 1:');
23 dispatchWheelEvent(input, 0, 1);
24 shouldBeEqualToString('input.value', stepUpValue1);
26 debug('Wheel up by 100:');
27 dispatchWheelEvent(input, 0, 100);
28 shouldBeEqualToString('input.value', stepUpValue2);
30 debug('Wheel down by 1:');
31 dispatchWheelEvent(input, 0, -1);
32 shouldBeEqualToString('input.value', stepUpValue1);
34 debug('Wheel down by 256:');
35 dispatchWheelEvent(input, 0, -256);
36 shouldBeEqualToString('input.value', initialValue);
38 debug('Disabled input element:');
39 input.disabled = true;
40 dispatchWheelEvent(input, 0, 1);
41 shouldBeEqualToString('input.value', initialValue);
42 input.removeAttribute('disabled');
45 debug('Read-only input element:');
46 input.readOnly = true;
47 dispatchWheelEvent(input, 0, 1);
48 shouldBeEqualToString('input.value', initialValue);
49 input.readOnly = false;
52 document.getElementById('another').focus();
53 dispatchWheelEvent(input, 0, 1);
54 shouldBeEqualToString('input.value', initialValue);
56 parent.parentNode.removeChild(parent);