diff options
| author | Stephen Blott | 2015-05-05 07:32:36 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-05 07:32:36 +0100 |
| commit | 290f5877b95585e73c6ac1b73b11d8df39b724cd (patch) | |
| tree | b7fd2afeece862c38cf329bb425c816c58e68045 | |
| parent | 3443059a19fc35ed687c8f1987c8a149a085ee93 (diff) | |
| download | vimium-290f5877b95585e73c6ac1b73b11d8df39b724cd.tar.bz2 | |
Guard against missing sender.
When a tab is closing, Chrome sometimes doesn't set sender.tab. To
reproduce, navigate (by entering the URLs directly) between www.bing.com
and www.google.com.
Fixes #1630. Partially. We still have a space leak.
| -rw-r--r-- | background_scripts/main.coffee | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 37c65592..103cc61e 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -385,7 +385,8 @@ setIcon = (request, sender) -> chrome.browserAction.setIcon tabId: sender.tab.id, path: path handleUpdateScrollPosition = (request, sender) -> - updateScrollPosition(sender.tab, request.scrollX, request.scrollY) + # See note re. sender.tab at unregisterFrame. + updateScrollPosition sender.tab, request.scrollX, request.scrollY if sender.tab? updateScrollPosition = (tab, scrollX, scrollY) -> tabInfoMap[tab.id].scrollX = scrollX @@ -598,8 +599,11 @@ registerFrame = (request, sender) -> (frameIdsForTab[sender.tab.id] ?= []).push request.frameId unregisterFrame = (request, sender) -> - tabId = sender.tab.id - if frameIdsForTab[tabId]? + # When a tab is closing, Chrome sometimes passes on messages without sender.tab. Therefore, we guard + # against this. + # FIXME(smblott) Consequently, we have a space leak in frameIdsForTab, tabInfoMap and urlForTab. + tabId = sender.tab?.id + if tabId? and frameIdsForTab[tabId]? if request.tab_is_closing updateOpenTabs sender.tab, true else |
