Index: LayoutTests/fast/forms/focus-on-control-with-zero-size.html |
diff --git a/LayoutTests/fast/forms/focus-on-control-with-zero-size.html b/LayoutTests/fast/forms/focus-on-control-with-zero-size.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..20320982100fa309d453fd85baf39a2a2ec4cf79 |
--- /dev/null |
+++ b/LayoutTests/fast/forms/focus-on-control-with-zero-size.html |
@@ -0,0 +1,56 @@ |
+<!DOCTYPE html> |
+<body> |
+<script src="../js/resources/js-test-pre.js"></script> |
+<style> |
+input { |
+ border: none; |
+ padding: 0; |
+ margin: 0; |
+} |
+</style> |
+<input id="input1"> |
+<script> |
+function handleKeydown(event) { |
+ event.target.style.width = '0px'; |
+} |
+ |
+function handleBlur(event) { |
+ testFailed('Event: blur'); |
+ event.target.style.width = ''; |
+} |
+ |
+window.onload = function() { |
+ debug('Check if a control won\'t loose focus when it becomes 0-size.'); |
+ input1.focus(); |
+ input1.addEventListener('keydown', handleKeydown, false); |
+ input1.addEventListener('blur', handleBlur, false); |
+ eventSender.keyDown('0'); |
+ event.target.removeEventListener('keydown', handleKeydown); |
+ setTimeout(step2, 1); |
+}; |
+ |
+function step2() { |
+ // We need to check activeElement twice because |
+ // FrameSelection::setFocusedNodeIfNeeded can change focus. |
+ shouldBe('document.activeElement', 'input1'); |
+ eventSender.keyDown('1'); |
+ shouldBeEqualToString('input1.value', '01'); |
+ shouldBe('document.activeElement', 'input1'); |
+ |
+ debug(''); |
+ debug('Check if 0-size control can get focus.'); |
+ input1.removeEventListener('blur', handleBlur); |
+ input1.blur(); |
+ shouldBe('document.activeElement', 'document.body', true); |
+ input1.style.height = '0px'; |
+ shouldBe('input1.offsetHeight', '0', true); |
+ input1.focus(); |
+ shouldBe('document.activeElement', 'input1'); |
+ |
+ finishJSTest(); |
+} |
+ |
+jsTestIsAsync = true; |
+</script> |
+<script src="../js/resources/js-test-post.js"></script> |
+</body> |