4 <script src=
"../../../resources/js-test.js"></script>
8 description('Test for spinbutton behavior for out-of-range values.');
10 var parent
= document
.createElement('div');
11 document
.body
.appendChild(parent
);
12 parent
.innerHTML
= '<input type=number id=lower value=-10 min=0 max=100>'
13 + '<input type=number id=higher value=200 min=0 max=100>';
14 var lower
= document
.getElementById('lower');
15 var higher
= document
.getElementById('higher');
17 function sendKeyEvent(element
, key
)
20 var event
= document
.createEvent('KeyboardEvents');
21 event
.initKeyboardEvent('keydown', true, true, document
.defaultView
, key
, 0, false, false, false, false, false);
22 element
.dispatchEvent(event
);
25 debug('Pressing the down arrow key on an input field of which value is lower than the minimum:');
26 sendKeyEvent(lower
, 'Down');
27 var unchanged
= "-10";
28 shouldBe('lower.value', 'unchanged');
30 debug('Pressing the up arrow key on the input:');
31 sendKeyEvent(lower
, 'Up');
32 shouldBe('lower.value', 'lower.min');
34 debug('Pressing the up arrow key on an input field of which value is higher than the maximum:');
35 sendKeyEvent(higher
, 'Up');
37 shouldBe('higher.value', 'unchanged');
39 debug('Pressing the down arrow key on the input:');
40 sendKeyEvent(higher
, 'Down');
41 shouldBe('higher.value', 'higher.max');
43 parent
.innerHTML
= '';