Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / number / number-blur-twice.html
blob2dea4cebdafc71b075db04f0a6047e00dc66c397
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <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>
8 <div id="console"></div>
10 <input type=number id=number>
11 <input type=text>
13 <script>
14 function handleFocus() {
15 numOfFocus++;
18 function handleBlur() {
19 numOfBlur++;
22 var numOfFocus = 0;
23 var numOfBlur = 0;
24 var num = document.getElementById('number');
25 num.addEventListener('focus', handleFocus);
26 num.addEventListener('blur', handleBlur);
27 num.focus();
28 document.execCommand('InsertText', false, '123');
29 document.execCommand('InsertText', false, 'a');
30 var tabEvent = document.createEvent('KeyboardEvent');
31 tabEvent.initKeyboardEvent('keydown', true, true, document.defaultView, 'U+0009');
32 num.dispatchEvent(tabEvent);
34 shouldBe('numOfFocus', '1');
35 shouldBe('numOfBlur', '1');
36 </script>
37 </body>
38 </html>