| <!DOCTYPE html> |
| <script src="../../../resources/js-test.js"></script> |
| <body> |
| <form> |
| <input type="text" id="text"> |
| <input type="date" id="date"> |
| <input type="time" id="time"> |
| </form> |
| <script> |
| description('Test Date/Time input field dispatches focusin event when pressed tab'); |
| var dispatchedFocusInEvent = 0; |
| var dispatchedDOMFocusInEvent = 0; |
| |
| document.documentElement.addEventListener('focusin', focusin, false); |
| document.documentElement.addEventListener('DOMFocusIn', domfocusin, false); |
| |
| function focusin() |
| { |
| dispatchedFocusInEvent++; |
| } |
| |
| function domfocusin() |
| { |
| dispatchedDOMFocusInEvent++; |
| } |
| |
| document.getElementById('text').focus(); |
| shouldBeEqualToString('document.activeElement.id', 'text'); |
| shouldBe('dispatchedFocusInEvent', '1'); |
| shouldBe('dispatchedDOMFocusInEvent', '1'); |
| |
| debug('Move to date field, should generate foucsin event'); |
| eventSender.keyDown('\t'); // move to date input element. |
| shouldBeEqualToString('document.activeElement.id', 'date'); |
| shouldBe('dispatchedFocusInEvent', '2'); |
| shouldBe('dispatchedDOMFocusInEvent', '2'); |
| eventSender.keyDown('\t'); // move to date field. |
| eventSender.keyDown('\t'); // move to year field. |
| |
| debug('Move to time field, should generate foucsin event'); |
| eventSender.keyDown('\t'); // move to time field. |
| shouldBeEqualToString('document.activeElement.id', 'time'); |
| shouldBe('dispatchedFocusInEvent', '3'); |
| shouldBe('dispatchedDOMFocusInEvent', '3'); |
| |
| </script> |
| </body> |