diff options
| -rw-r--r-- | content_scripts/mode_normal.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 2 | ||||
| -rw-r--r-- | lib/utils.coffee | 8 | ||||
| -rw-r--r-- | tests/unit_tests/utils_test.coffee | 20 |
4 files changed, 2 insertions, 30 deletions
diff --git a/content_scripts/mode_normal.coffee b/content_scripts/mode_normal.coffee index 6db42948..d6f2934e 100644 --- a/content_scripts/mode_normal.coffee +++ b/content_scripts/mode_normal.coffee @@ -31,7 +31,7 @@ class NormalMode extends KeyHandlerMode else if registryEntry.background chrome.runtime.sendMessage {handler: "runBackgroundCommand", registryEntry, count} else - Utils.invokeCommandString registryEntry.command, count, {registryEntry} + NormalModeCommands[registryEntry.command] count, {registryEntry} enterNormalMode = (count) -> new NormalMode diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5549664e..b936fe04 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -142,7 +142,7 @@ initializePreDomReady = -> frameFocused: -> # A frame has received the focus; we don't care here (UI components handle this). checkEnabledAfterURLChange: checkEnabledAfterURLChange runInTopFrame: ({sourceFrameId, registryEntry}) -> - Utils.invokeCommandString registryEntry.command, sourceFrameId, registryEntry if DomUtils.isTopFrame() + NormalModeCommands[registryEntry.command] sourceFrameId, registryEntry if DomUtils.isTopFrame() linkHintsMessage: (request) -> HintCoordinator[request.messageType] request chrome.runtime.onMessage.addListener (request, sender, sendResponse) -> diff --git a/lib/utils.coffee b/lib/utils.coffee index b5b96844..6f38be8f 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -32,14 +32,6 @@ Utils = # Returns true whenever the current page is the extension's background page. isBackgroundPage: -> @isExtensionPage() and chrome.extension.getBackgroundPage?() == window - # Takes a dot-notation object string and calls the function that it points to with the correct value for - # 'this'. - invokeCommandString: (str, args...) -> - [names..., name] = str.split '.' - obj = window - obj = obj[component] for component in names - obj[name].apply obj, args - # Escape all special characters, so RegExp will parse the string 'as is'. # Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex escapeRegexSpecialCharacters: do -> diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee index cc1081dd..2794a6d7 100644 --- a/tests/unit_tests/utils_test.coffee +++ b/tests/unit_tests/utils_test.coffee @@ -138,26 +138,6 @@ context "distinctCharacters", should "eliminate duplicate characters", -> assert.equal "abc", Utils.distinctCharacters "bbabaabbacabbbab" -context "invokeCommandString", - setup -> - @beenCalled = false - window.singleComponentCommand = => @beenCalled = true - window.twoComponentCommand = command: window.singleComponentCommand - - tearDown -> - delete window.singleComponentCommand - delete window.twoComponentCommand - - should "invoke single-component commands", -> - assert.isFalse @beenCalled - Utils.invokeCommandString "singleComponentCommand" - assert.isTrue @beenCalled - - should "invoke multi-component commands", -> - assert.isFalse @beenCalled - Utils.invokeCommandString "twoComponentCommand.command" - assert.isTrue @beenCalled - context "escapeRegexSpecialCharacters", should "escape regexp special characters", -> str = "-[]/{}()*+?.^$|" |
