1 var inputEventCounter = 0;
2 var changeEventCounter = 0;
5 function testClearButtonChangeAndInputEvents(inputType, initialValue)
7 description('Test for event dispatching by spin buttons in a type=' + inputType + ' input.');
8 if (!window.eventSender) {
9 debug('No eventSender');
13 testInput = document.createElement('input');
14 testInput.type = inputType;
15 testInput.value = initialValue;
16 testInput.onchange = function() { changeEventCounter++; };
17 testInput.oninput = function() { inputEventCounter++; };
18 document.body.appendChild(testInput);
19 var anotherInput = document.createElement('input');
20 document.body.appendChild(anotherInput);
22 debug('Initial state');
23 eventSender.mouseMoveTo(0, 0);
24 shouldEvaluateTo('changeEventCounter', 0);
25 shouldEvaluateTo('inputEventCounter', 0);
27 debug('Click the clear button');
28 // Move the cursor on to the clear button.
29 var clearButton = getElementByPseudoId(internals.oldestShadowRoot(testInput), "-webkit-clear-button");
30 eventSender.mouseMoveTo(clearButton.offsetLeft + clearButton.offsetWidth / 2, clearButton.offsetTop + clearButton.offsetHeight / 2);
31 eventSender.mouseDown();
32 eventSender.mouseUp();
33 shouldBeEqualToString('testInput.value', '');
34 shouldEvaluateTo('changeEventCounter', 1);
35 shouldEvaluateTo('inputEventCounter', 1);
37 debug('Focus on another field');
39 shouldEvaluateTo('changeEventCounter', 1);
40 shouldEvaluateTo('inputEventCounter', 1);
42 parent.innerHTML = '';