Git init
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / input-number-blur-twice.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
5 <script src="../../fast/js/resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <p id="description">There was a bug that moving focus with TAB from a number input with an invalid string dispatched an extra focus event and an extra blur event.</p>
9 <div id="console"></div>
10
11 <input type=number id=number>
12 <input type=text>
13
14 <script>
15 function handleFocus() {
16     numOfFocus++;
17 }
18
19 function handleBlur() {
20     numOfBlur++;
21 }
22
23 var numOfFocus = 0;
24 var numOfBlur = 0;
25 var num = document.getElementById('number');
26 num.addEventListener('focus', handleFocus);
27 num.addEventListener('blur', handleBlur);
28 num.focus();
29 document.execCommand('InsertText', false, '123');
30 document.execCommand('InsertText', false, 'a');
31 var tabEvent = document.createEvent('KeyboardEvent');
32 tabEvent.initKeyboardEvent('keydown', true, true, document.defaultView, 'U+0009');
33 num.dispatchEvent(tabEvent);
34
35 shouldBe('numOfFocus', '1');
36 shouldBe('numOfBlur', '1');
37
38 var successfullyParsed = true;
39 </script>
40 <script src="../../fast/js/resources/js-test-post.js"></script>
41 </body>
42 </html>