diff options
| -rw-r--r-- | background_scripts/main.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 10 | ||||
| -rw-r--r-- | tests/unit_tests/exclusion_test.coffee | 2 |
3 files changed, 8 insertions, 14 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 25aaef7b..42e9b344 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -354,9 +354,8 @@ openOptionsPageInNewTab = -> Frames = onConnect: (sender, port) -> [tabId, frameId] = [sender.tab.id, sender.frameId] - # We always add frameId 0, the top frame, automatically, and never unregister it. - frameIdsForTab[tabId] ?= [0] - frameIdsForTab[tabId].push frameId unless frameId == 0 + frameIdsForTab[tabId] ?= [] + frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId] port.postMessage handler: "registerFrameId", chromeFrameId: frameId port.onDisconnect.addListener listener = -> @@ -386,16 +385,13 @@ Frames = handleFrameFocused = (request, sender) -> [tabId, frameId] = [sender.tab.id, sender.frameId] - # This might be the first time we've heard from this tab. - frameIdsForTab[tabId] ?= [0] - # Cycle frameIdsForTab to the focused frame. + frameIdsForTab[tabId] ?= [] frameIdsForTab[tabId] = cycleToFrame frameIdsForTab[tabId], frameId # Inform all frames that a frame has received the focus. chrome.tabs.sendMessage tabId, name: "frameFocused", focusFrameId: frameId # Rotate through frames to the frame count places after frameId. cycleToFrame = (frames, frameId, count = 0) -> - frames ||= [] # We can't always track which frame chrome has focussed, but here we learn that it's frameId; so add an # additional offset such that we do indeed start from frameId. count = (count + Math.max 0, frames.indexOf frameId) % frames.length diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 36ca7834..a538e46e 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -1,5 +1,5 @@ # -# This content script must be run prior to domReady so that we perform some operations very early. +# This content script must be run prior to domReady so that we perform some operations very early. # isEnabledForUrl = true @@ -224,12 +224,10 @@ Frame = @port.onMessage.addListener (request) => handler request for handler in @listeners[request.handler] - @port.onDisconnect.addListener => - # We disable content scripts when we lose contact with the background page. + @port.onDisconnect.addListener -> + # We disable the content scripts when we lose contact with the background page. isEnabledForUrl = false - chrome.runtime.sendMessage = -> window.removeEventListener "focus", onFocus - @port.postMessage = -> handleShowHUDforDuration = ({ text, duration }) -> if DomUtils.isTopFrame() @@ -271,7 +269,7 @@ focusThisFrame = (request) -> unless request.forceFocusThisFrame if window.innerWidth < 3 or window.innerHeight < 3 or document.body?.tagName.toLowerCase() == "frameset" # This frame is too small to focus or it's a frameset. Cancel and tell the background page to focus the - # next frame instead. This affects sites like Google Inbox, which have many tiny iframes. See 1317. + # next frame instead. This affects sites like Google Inbox, which have many tiny iframes. See #1317. chrome.runtime.sendMessage handler: "nextFrame", frameId: frameId return window.focus() diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee index 33b04777..649dfd1f 100644 --- a/tests/unit_tests/exclusion_test.coffee +++ b/tests/unit_tests/exclusion_test.coffee @@ -20,7 +20,7 @@ extend(global, require "../../background_scripts/commands.js") extend(global, require "../../background_scripts/main.js") isEnabledForUrl = (request) -> - Frames.isEnabledForUrl {request, tabId: 0, port: postMessage: (id) -> id} + Frames.isEnabledForUrl {request, tabId: 0, port: postMessage: (request) -> request} # These tests cover only the most basic aspects of excluded URLs and passKeys. # |
