aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-10-31 15:02:37 +0000
committerStephen Blott2014-10-31 15:02:37 +0000
commit390a9cb85e2a97fbd9d2b1a400deee4b12394337 (patch)
tree797e8889b2548123fedea80bc3548ff58a3e82aa
parent3e175bcf39d4794937ca493f27c06bb63d739c63 (diff)
downloadvimium-390a9cb85e2a97fbd9d2b1a400deee4b12394337.tar.bz2
Fix vomnibar/iframe tests.
-rw-r--r--pages/vomnibar.coffee75
-rw-r--r--tests/dom_tests/dom_tests.html5
-rw-r--r--tests/dom_tests/vomnibar_test.coffee2
3 files changed, 32 insertions, 50 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index ece0d756..8b2661fe 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -5,6 +5,7 @@
#
Vomnibar =
vomnibarUI: null # the dialog instance for this window
+ getUI: -> @vomnibarUI
completers: {}
getCompleter: (name) ->
@@ -15,7 +16,31 @@ Vomnibar =
#
# Activate the Vomnibox.
#
- activateWithCompleter: (options) ->
+ activate: (params = "") ->
+ options =
+ completer: "omni"
+ query: null
+ frameId: -1
+
+ booleanOptions = ["selectFirst", "newTab"]
+
+ # Convert options/params in URL to options object.
+ params
+ .split(/[\?&]/)
+ .map((option) ->
+ [name, value] = option.split "="
+ options[name] = value
+ options[name] = unescape(value) if value
+ )
+
+ # Set boolean options.
+ for option in booleanOptions
+ options[option] = option of options and options[option] != "false"
+
+ options.refreshInterval = switch options.completer
+ when "omni" then 100
+ else 0
+
completer = @getCompleter(options.completer)
@vomnibarUI ?= new VomnibarUI()
completer.refresh()
@@ -29,28 +54,6 @@ Vomnibar =
@vomnibarUI.setQuery(options.query)
@vomnibarUI.update()
- activate: -> @activateWithCompleter {completer:"omni"}
- activateInNewTab: -> @activateWithCompleter {
- completer: "omni"
- selectFirst: false
- newTab: true
- }
- activateTabSelection: -> @activateWithCompleter {
- completer: "tabs"
- selectFirst: true
- }
- activateBookmarks: -> @activateWithCompleter {
- completer: "bookmarks"
- selectFirst: true
- }
- activateBookmarksInNewTab: -> @activateWithCompleter {
- completer: "bookmarks"
- selectFirst: true
- newTab: true
- }
- getUI: -> @vomnibarUI
-
-
class VomnibarUI
constructor: ->
@refreshInterval = 0
@@ -258,31 +261,7 @@ extend BackgroundCompleter,
switchToTab: (tabId) -> chrome.runtime.sendMessage({ handler: "selectSpecificTab", id: tabId })
initializeOnDomReady = ->
- options =
- completer: "omni"
- query: null
- frameId: -1
-
- booleanOptions = ["selectFirst", "newTab"]
-
- # Convert options in URL to options object
- document.location.search
- .split(/[\?&]/)
- .map((option) ->
- [name, value] = option.split "="
- options[name] = value
- options[name] = unescape(value) if value
- )
-
- # Set boolean options
- for option in booleanOptions
- options[option] = option of options and options[option] != "false"
-
- options.refreshInterval = switch options.completer
- when "omni" then 100
- else 0
-
- Vomnibar.activateWithCompleter options
+ Vomnibar.activate document.location.search
window.addEventListener "DOMContentLoaded", initializeOnDomReady
diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html
index e6427e85..6378807f 100644
--- a/tests/dom_tests/dom_tests.html
+++ b/tests/dom_tests/dom_tests.html
@@ -35,7 +35,10 @@
<script type="text/javascript" src="../../lib/handler_stack.js"></script>
<script type="text/javascript" src="../../lib/clipboard.js"></script>
<script type="text/javascript" src="../../content_scripts/link_hints.js"></script>
- <script type="text/javascript" src="../../content_scripts/vomnibar.js"></script>
+ <!-- TODO(smblott) The following is being overridden by the inclusion of "../../pages/vomnibar.js", below,
+ because they both define the same Vomnibar class/object. As a result, there are currently no tests
+ testing the DOM aspects of "../../content_scripts/vomnibar.js".
+ <script type="text/javascript" src="../../content_scripts/vomnibar.js"></script> -->
<script type="text/javascript" src="../../content_scripts/scroller.js"></script>
<script type="text/javascript" src="../../content_scripts/vimium_frontend.js"></script>
<script type="text/javascript" src="../../pages/vomnibar.js"></script>
diff --git a/tests/dom_tests/vomnibar_test.coffee b/tests/dom_tests/vomnibar_test.coffee
index dc2a849f..f7241552 100644
--- a/tests/dom_tests/vomnibar_test.coffee
+++ b/tests/dom_tests/vomnibar_test.coffee
@@ -28,7 +28,7 @@ context "Keep selection within bounds",
assert.equal -1, ui.selection
should "set selection to position 0 for bookmark completion if possible", ->
- Vomnibar.activateBookmarks()
+ Vomnibar.activate "completer=bookmark&selectFirst"
ui = Vomnibar.vomnibarUI
@completions = []