aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-17 12:35:33 +0000
committerStephen Blott2016-03-17 12:35:33 +0000
commit16b150c108f72cc7b3e33c6fa46bd5c2d06c71c8 (patch)
treea0af536d219e1728d6f483cb0b39f6ca1a89e524
parentd6f8e7301ed43a64df77e9bfa0ef9dd7a263faeb (diff)
downloadvimium-16b150c108f72cc7b3e33c6fa46bd5c2d06c71c8.tar.bz2
Tweaks for #2053.
-rw-r--r--background_scripts/main.coffee10
-rw-r--r--content_scripts/vimium_frontend.coffee10
-rw-r--r--tests/unit_tests/exclusion_test.coffee2
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.
#