aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion.coffee2
-rw-r--r--background_scripts/main.coffee12
2 files changed, 9 insertions, 5 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 7cd47a00..66ad2e38 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -779,7 +779,7 @@ HistoryCache =
# correct "lastVisitTime". That's crucial for ranking Vomnibar suggestions.
onPageVisited: (newPage) ->
i = HistoryCache.binarySearch(newPage, @history, @compareHistoryByUrl)
- pageWasFound = (@history[i].url == newPage.url)
+ pageWasFound = (@history[i]?.url == newPage.url)
if pageWasFound
@history[i] = newPage
else
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 9f04d1c0..76fbcd96 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -301,10 +301,14 @@ Frames =
(portsForTab[tabId] ?= {})[frameId] = port
unregisterFrame: ({tabId, frameId}) ->
- if tabId of frameIdsForTab
- frameIdsForTab[tabId] = (fId for fId in frameIdsForTab[tabId] when fId != frameId)
- if tabId of portsForTab
- delete portsForTab[tabId][frameId]
+ # FrameId 0 is the top/main frame. We never unregister that frame. If the tab is closing, then we tidy
+ # up elsewhere. If the tab is navigating to a new page, then a new top frame will be along soon.
+ # This mitigates against the unregister and register messages arriving in the "wrong" order.
+ if 0 < frameId
+ if tabId of frameIdsForTab
+ frameIdsForTab[tabId] = (fId for fId in frameIdsForTab[tabId] when fId != frameId)
+ if tabId of portsForTab
+ delete portsForTab[tabId][frameId]
HintCoordinator.unregisterFrame tabId, frameId
isEnabledForUrl: ({request, tabId, port}) ->