aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932015-02-18 00:51:51 +0000
committermrmr19932015-02-18 01:12:04 +0000
commitdfc84985802529be1cc32552d7c8016bf2e56dad (patch)
tree2976b62e8d00ffc810322073fd9ca2684510c779
parent90f906b626d370a82f5143f84bf1384060386e46 (diff)
downloadvimium-dfc84985802529be1cc32552d7c8016bf2e56dad.tar.bz2
Add a test for link hints on HTML5 input types
-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 ->