aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2015-03-06 11:47:39 +0000
committerStephen Blott2015-03-06 11:47:39 +0000
commit29eb444f2fb519a0cae32363d8462aa06ef133a7 (patch)
tree6bd3289189ac14fee2b4c86feed735b3ef48997a /tests
parentc2638cd00b19e04bdfed164de6b1a3d4051cfbd9 (diff)
parentb959fa5c6b36ba19340f195d822b4b3cca8ccd2d (diff)
downloadvimium-29eb444f2fb519a0cae32363d8462aa06ef133a7.tar.bz2
Merge branch 'fix-focus-html5-inputs'
Diffstat (limited to 'tests')
-rw-r--r--tests/dom_tests/dom_tests.coffee41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index a1ca8723..600616a9 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -84,6 +84,47 @@ createGeneralHintTests = (isFilteredMode) ->
createGeneralHintTests false
createGeneralHintTests true
+inputs = []
+context "Test link hints for focusing input elements correctly",
+
+ setup ->
+ initializeModeState()
+ testDiv = document.getElementById("test-div")
+ testDiv.innerHTML = ""
+
+ stub settings.values, "filterLinkHints", false
+ stub settings.values, "linkHintCharacters", "ab"
+
+ # Every HTML5 input type except for hidden. We should be able to activate all of them with link hints.
+ inputTypes = ["button", "checkbox", "color", "date", "datetime", "datetime-local", "email", "file",
+ "image", "month", "number", "password", "radio", "range", "reset", "search", "submit", "tel", "text",
+ "time", "url", "week"]
+
+ for type in inputTypes
+ input = document.createElement "input"
+ input.type = type
+ testDiv.appendChild input
+ inputs.push input
+
+ tearDown ->
+ document.getElementById("test-div").innerHTML = ""
+
+ should "Focus each input when its hint text is typed", ->
+ for input in inputs
+ input.scrollIntoView() # Ensure the element is visible so we create a link hint for it.
+
+ activeListener = ensureCalled (event) ->
+ input.blur() if event.type == "focus"
+ input.addEventListener "focus", activeListener, false
+ input.addEventListener "click", activeListener, false
+
+ LinkHints.activateMode()
+ [hint] = getHintMarkers().filter (hint) -> input == hint.clickableItem
+ sendKeyboardEvent char for char in hint.hintString
+
+ input.removeEventListener "focus", activeListener, false
+ input.removeEventListener "click", activeListener, false
+
context "Alphabetical link hints",
setup ->