Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: LayoutTests/fast/forms/focus-on-control-with-zero-size.html

Issue 23496036: Make it possible to focus on 0-size form controls and anchors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698