diff options
| author | mrmr1993 | 2014-12-29 19:26:26 +0000 | 
|---|---|---|
| committer | mrmr1993 | 2014-12-29 19:26:26 +0000 | 
| commit | b5e9dcb5f87391c0da937517182889eb47ec8f0a (patch) | |
| tree | f12ab3ea4fe315347e16c4e640f6a6e0e8765116 | |
| parent | 57418a9ad6104c487b67fcfd27ec8503858e5a14 (diff) | |
| download | vimium-b5e9dcb5f87391c0da937517182889eb47ec8f0a.tar.bz2 | |
Fix tests for UIComponent Vomnibar iframe
| -rw-r--r-- | tests/dom_tests/dom_tests.html | 17 | ||||
| -rw-r--r-- | tests/dom_tests/vomnibar_test.coffee | 27 | 
2 files changed, 22 insertions, 22 deletions
| diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html index 863c5611..7b154d24 100644 --- a/tests/dom_tests/dom_tests.html +++ b/tests/dom_tests/dom_tests.html @@ -36,13 +36,9 @@      <script type="text/javascript" src="../../lib/clipboard.js"></script>      <script type="text/javascript" src="../../content_scripts/ui_component.js"></script>      <script type="text/javascript" src="../../content_scripts/link_hints.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/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>      <script type="text/javascript" src="../shoulda.js/shoulda.js"></script>      <script type="text/javascript" src="dom_tests.js"></script> @@ -57,16 +53,5 @@      <h1>Vimium Tests</h1>      <div id="output-div"></div> - -    <!-- This is a hack to keep Vomnibar tests working after moving it to an iframe. -         The following are the elements from the iframe so that we can embed the iframe's script without errors. -         TODO(mrmr1993): Look into rewriting the Vomnibar tests so we don't need this. --> -    <div id="vomnibar" class="vimiumReset"> -      <div class="vimiumReset vomnibarSearchArea"> -        <input type="text" class="vimiumReset"> -      </div> -      <ul class="vimiumReset"></ul> -    </div> -    </body>  </html> diff --git a/tests/dom_tests/vomnibar_test.coffee b/tests/dom_tests/vomnibar_test.coffee index f660f96b..0e02bb7b 100644 --- a/tests/dom_tests/vomnibar_test.coffee +++ b/tests/dom_tests/vomnibar_test.coffee @@ -1,19 +1,34 @@ +vomnibarFrame = null +  context "Keep selection within bounds",    setup ->      @completions = [] -    oldGetCompleter = Vomnibar.getCompleter.bind Vomnibar -    stub Vomnibar, 'getCompleter', (name) => + +    vomnibarFrame = Vomnibar.vomnibarUI.iframeElement.contentWindow + +    # The Vomnibar frame is dynamically injected, so inject our stubs here. +    vomnibarFrame.Function::bind = Function::bind +    vomnibarFrame.chrome = chrome + +    oldGetCompleter = vomnibarFrame.Vomnibar.getCompleter.bind vomnibarFrame.Vomnibar +    stub vomnibarFrame.Vomnibar, 'getCompleter', (name) =>        completer = oldGetCompleter name        stub completer, 'filter', (query, callback) => callback(@completions)        completer +    # Shoulda.js doesn't support async tests, so we have to hack around. +    stub Vomnibar.vomnibarUI, "postMessage", (data) -> +      vomnibarFrame.UIComponentServer.handleMessage {data} +    stub vomnibarFrame.UIComponentServer, "postMessage", (data) -> +      UIComponent.handleMessage {data} +    tearDown ->      Vomnibar.vomnibarUI.hide()    should "set selection to position -1 for omni completion by default", ->      Vomnibar.activate() -    ui = Vomnibar.vomnibarUI +    ui = vomnibarFrame.Vomnibar.vomnibarUI      @completions = []      ui.update(true) @@ -28,8 +43,8 @@ context "Keep selection within bounds",      assert.equal -1, ui.selection    should "set selection to position 0 for bookmark completion if possible", -> -    Vomnibar.activate "completer=bookmark&selectFirst" -    ui = Vomnibar.vomnibarUI +    Vomnibar.activateBookmarks() +    ui = vomnibarFrame.Vomnibar.vomnibarUI      @completions = []      ui.update(true) @@ -45,7 +60,7 @@ context "Keep selection within bounds",    should "keep selection within bounds", ->      Vomnibar.activate() -    ui = Vomnibar.vomnibarUI +    ui = vomnibarFrame.Vomnibar.vomnibarUI      @completions = []      ui.update(true) | 
