diff options
| author | Stephen Blott | 2015-02-21 06:45:54 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-02-23 06:25:48 +0000 |
| commit | 731d45a8e8faf1f209632d5093bef5b554e26bb6 (patch) | |
| tree | de9d18e0ec901410c124f8ee62d6c8ee77592217 | |
| parent | 30485767273aabdd1190ba84b3002f8f15526695 (diff) | |
| download | vimium-731d45a8e8faf1f209632d5093bef5b554e26bb6.tar.bz2 | |
Ensure inconito mode flag and find-mode-history are initialised.
See #1495.
| -rw-r--r-- | background_scripts/main.coffee | 5 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 2 | ||||
| -rw-r--r-- | tests/dom_tests/chrome.coffee | 2 | ||||
| -rw-r--r-- | tests/unit_tests/exclusion_test.coffee | 12 |
4 files changed, 14 insertions, 7 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 1301cb77..9eafc2a2 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -77,11 +77,12 @@ getCurrentTabUrl = (request, sender) -> sender.tab.url # Checks the user's preferences in local storage to determine if Vimium is enabled for the given URL, and # whether any keys should be passed through to the underlying page. # -root.isEnabledForUrl = isEnabledForUrl = (request) -> +root.isEnabledForUrl = isEnabledForUrl = (request, sender) -> rule = Exclusions.getRule(request.url) { isEnabledForUrl: not rule or rule.passKeys passKeys: rule?.passKeys or "" + incognito: sender.tab.incognito } # Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. @@ -371,7 +372,7 @@ root.updateActiveState = updateActiveState = (tabId) -> if response isCurrentlyEnabled = response.enabled currentPasskeys = response.passKeys - config = isEnabledForUrl({url: tab.url}) + config = isEnabledForUrl { url: tab.url }, { tab: tab } enabled = config.isEnabledForUrl passKeys = config.passKeys if (enabled and passKeys) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 609b6b40..28c1f092 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -211,13 +211,13 @@ window.initializeWhenEnabled = -> do (type) -> installListener window, type, (event) -> handlerStack.bubbleEvent type, event installListener document, "DOMActivate", (event) -> handlerStack.bubbleEvent 'DOMActivate', event installedListeners = true + FindModeHistory.init() setState = (request) -> isEnabledForUrl = request.enabled passKeys = request.passKeys isIncognitoMode = request.incognito initializeWhenEnabled() if isEnabledForUrl - FindModeHistory.init() handlerStack.bubbleEvent "registerStateChange", enabled: isEnabledForUrl passKeys: passKeys diff --git a/tests/dom_tests/chrome.coffee b/tests/dom_tests/chrome.coffee index d6c03fc1..5f276649 100644 --- a/tests/dom_tests/chrome.coffee +++ b/tests/dom_tests/chrome.coffee @@ -27,3 +27,5 @@ root.chrome = sync: get: -> set: -> + onChanged: + addListener: -> diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee index b3ed7194..287d699d 100644 --- a/tests/unit_tests/exclusion_test.coffee +++ b/tests/unit_tests/exclusion_test.coffee @@ -21,6 +21,10 @@ extend(global, require "../../background_scripts/exclusions.js") extend(global, require "../../background_scripts/commands.js") extend(global, require "../../background_scripts/main.js") +dummyTab = + tab: + incognito: false + # These tests cover only the most basic aspects of excluded URLs and passKeys. # context "Excluded URLs and pass keys", @@ -36,22 +40,22 @@ context "Excluded URLs and pass keys", ]) should "be disabled for excluded sites", -> - rule = isEnabledForUrl({ url: 'http://mail.google.com/calendar/page' }) + rule = isEnabledForUrl({ url: 'http://mail.google.com/calendar/page' }, dummyTab) assert.isFalse rule.isEnabledForUrl assert.isFalse rule.passKeys should "be disabled for excluded sites, one exclusion", -> - rule = isEnabledForUrl({ url: 'http://www.bbc.com/calendar/page' }) + rule = isEnabledForUrl({ url: 'http://www.bbc.com/calendar/page' }, dummyTab) assert.isFalse rule.isEnabledForUrl assert.isFalse rule.passKeys should "be enabled, but with pass keys", -> - rule = isEnabledForUrl({ url: 'https://www.facebook.com/something' }) + rule = isEnabledForUrl({ url: 'https://www.facebook.com/something' }, dummyTab) assert.isTrue rule.isEnabledForUrl assert.equal rule.passKeys, 'abcd' should "be enabled", -> - rule = isEnabledForUrl({ url: 'http://www.twitter.com/pages' }) + rule = isEnabledForUrl({ url: 'http://www.twitter.com/pages' }, dummyTab) assert.isTrue rule.isEnabledForUrl assert.isFalse rule.passKeys |
