diff options
| author | mrmr1993 | 2015-02-18 00:51:51 +0000 |
|---|---|---|
| committer | mrmr1993 | 2015-02-18 01:12:04 +0000 |
| commit | dfc84985802529be1cc32552d7c8016bf2e56dad (patch) | |
| tree | 2976b62e8d00ffc810322073fd9ca2684510c779 | |
| parent | 90f906b626d370a82f5143f84bf1384060386e46 (diff) | |
| download | vimium-dfc84985802529be1cc32552d7c8016bf2e56dad.tar.bz2 | |
Add a test for link hints on HTML5 input types
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 41 |
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 -> |
