OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <body> |
| 3 <script src="../js/resources/js-test-pre.js"></script> |
| 4 <style> |
| 5 input { |
| 6 border: none; |
| 7 padding: 0; |
| 8 margin: 0; |
| 9 } |
| 10 </style> |
| 11 <input id="input1"> |
| 12 <script> |
| 13 function handleKeydown(event) { |
| 14 event.target.style.width = '0px'; |
| 15 } |
| 16 |
| 17 function handleBlur(event) { |
| 18 testFailed('Event: blur'); |
| 19 event.target.style.width = ''; |
| 20 } |
| 21 |
| 22 window.onload = function() { |
| 23 debug('Check if a control won\'t loose focus when it becomes 0-size.'); |
| 24 input1.focus(); |
| 25 input1.addEventListener('keydown', handleKeydown, false); |
| 26 input1.addEventListener('blur', handleBlur, false); |
| 27 eventSender.keyDown('0'); |
| 28 event.target.removeEventListener('keydown', handleKeydown); |
| 29 setTimeout(step2, 1); |
| 30 }; |
| 31 |
| 32 function step2() { |
| 33 // We need to check activeElement twice because |
| 34 // FrameSelection::setFocusedNodeIfNeeded can change focus. |
| 35 shouldBe('document.activeElement', 'input1'); |
| 36 eventSender.keyDown('1'); |
| 37 shouldBeEqualToString('input1.value', '01'); |
| 38 shouldBe('document.activeElement', 'input1'); |
| 39 |
| 40 debug(''); |
| 41 debug('Check if 0-size control can get focus.'); |
| 42 input1.removeEventListener('blur', handleBlur); |
| 43 input1.blur(); |
| 44 shouldBe('document.activeElement', 'document.body', true); |
| 45 input1.style.height = '0px'; |
| 46 shouldBe('input1.offsetHeight', '0', true); |
| 47 input1.focus(); |
| 48 shouldBe('document.activeElement', 'input1'); |
| 49 |
| 50 finishJSTest(); |
| 51 } |
| 52 |
| 53 jsTestIsAsync = true; |
| 54 </script> |
| 55 <script src="../js/resources/js-test-post.js"></script> |
| 56 </body> |
OLD | NEW |