diff options
| author | mrmr1993 | 2015-05-31 16:35:09 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2015-05-31 17:51:01 +0100 | 
| commit | 0de6b076271b673d0e1dcc2b74b2ddd1646bf08e (patch) | |
| tree | c0e03c0c96ef2cc5057a983d142de579e5d7bf41 /tests | |
| parent | 257a219fdfd33c49b565a93dff9d785824533d2a (diff) | |
| download | vimium-0de6b076271b673d0e1dcc2b74b2ddd1646bf08e.tar.bz2 | |
Rewrite settings as a tight wrapper around Settings, tweaks for tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dom_tests/chrome.coffee | 6 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 30 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.html | 1 | 
3 files changed, 25 insertions, 12 deletions
| diff --git a/tests/dom_tests/chrome.coffee b/tests/dom_tests/chrome.coffee index 4c9bfa52..4de85876 100644 --- a/tests/dom_tests/chrome.coffee +++ b/tests/dom_tests/chrome.coffee @@ -7,6 +7,9 @@ root.chromeMessages = []  document.hasFocus = -> true +fakeManifest = +  version: "1.51" +  root.chrome =    runtime:      connect: -> @@ -18,7 +21,7 @@ root.chrome =      onMessage:        addListener: ->      sendMessage: (message) -> chromeMessages.unshift message -    getManifest: -> +    getManifest: -> fakeManifest      getURL: (url) -> "../../#{url}"    storage:      local: @@ -31,3 +34,4 @@ root.chrome =        addListener: ->    extension:      inIncognitoContext: false +    getURL: (url) -> chrome.runtime.getURL url diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 8c2b73c3..e57f3eab 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -34,12 +34,20 @@ initializeModeState = ->    handlerStack.bubbleEvent "registerKeyQueue",      keyQueue: "" +# Tell Settings that it's been loaded. +Settings.isLoaded = true + +# Shoulda.js doesn't support async code, so we try not to use any. +Utils.nextTick = (func) -> func() +  #  # Retrieve the hint markers as an array object.  #  getHintMarkers = ->    Array::slice.call document.getElementsByClassName("vimiumHintMarker"), 0 +stubSettings = (key, value) -> stub Settings.cache, key, JSON.stringify value +  #  # Generate tests that are common to both default and filtered  # link hinting modes. @@ -52,8 +60,8 @@ createGeneralHintTests = (isFilteredMode) ->        initializeModeState()        testContent = "<a>test</a>" + "<a>tress</a>"        document.getElementById("test-div").innerHTML = testContent -      stub settings.values, "filterLinkHints", false -      stub settings.values, "linkHintCharacters", "ab" +      stubSettings "filterLinkHints", false +      stubSettings "linkHintCharacters", "ab"      tearDown ->        document.getElementById("test-div").innerHTML = "" @@ -92,8 +100,8 @@ context "Test link hints for focusing input elements correctly",      testDiv = document.getElementById("test-div")      testDiv.innerHTML = "" -    stub settings.values, "filterLinkHints", false -    stub settings.values, "linkHintCharacters", "ab" +    stubSettings "filterLinkHints", false +    stubSettings "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", @@ -129,8 +137,8 @@ context "Alphabetical link hints",    setup ->      initializeModeState() -    stub settings.values, "filterLinkHints", false -    stub settings.values, "linkHintCharacters", "ab" +    stubSettings "filterLinkHints", false +    stubSettings "linkHintCharacters", "ab"      # Three hints will trigger double hint chars.      createLinks 3 @@ -161,8 +169,8 @@ context "Filtered link hints",    # elements.    setup -> -    stub settings.values, "filterLinkHints", true -    stub settings.values, "linkHintNumbers", "0123456789" +    stubSettings "filterLinkHints", true +    stubSettings "linkHintNumbers", "0123456789"    context "Text hints", @@ -289,7 +297,7 @@ context "Find prev / next links",      <a href='#first'>nextcorrupted</a>      <a href='#second'>next page</a>      """ -    stub settings.values, "nextPatterns", "next" +    stubSettings "nextPatterns", "next"      goNext()      assert.equal '#second', window.location.hash @@ -297,7 +305,7 @@ context "Find prev / next links",      document.getElementById("test-div").innerHTML = """      <a href='#first'>>></a>      """ -    stub settings.values, "nextPatterns", ">>" +    stubSettings "nextPatterns", ">>"      goNext()      assert.equal '#first', window.location.hash @@ -306,7 +314,7 @@ context "Find prev / next links",      <a href='#first'>lorem ipsum next</a>      <a href='#second'>next!</a>      """ -    stub settings.values, "nextPatterns", "next" +    stubSettings "nextPatterns", "next"      goNext()      assert.equal '#second', window.location.hash diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html index 5ccd39e7..f7cc430d 100644 --- a/tests/dom_tests/dom_tests.html +++ b/tests/dom_tests/dom_tests.html @@ -35,6 +35,7 @@      <script type="text/javascript" src="../../lib/rect.js"></script>      <script type="text/javascript" src="../../lib/handler_stack.js"></script>      <script type="text/javascript" src="../../lib/clipboard.js"></script> +    <script type="text/javascript" src="../../lib/settings.js"></script>      <script type="text/javascript" src="../../content_scripts/ui_component.js"></script>      <script type="text/javascript" src="../../content_scripts/link_hints.js"></script>      <script type="text/javascript" src="../../content_scripts/vomnibar.js"></script> | 
