aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS1
-rw-r--r--background_scripts/bg_utils.coffee5
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee2
3 files changed, 8 insertions, 0 deletions
diff --git a/CREDITS b/CREDITS
index e05a1c6a..b11497ca 100644
--- a/CREDITS
+++ b/CREDITS
@@ -44,5 +44,6 @@ Contributors:
Shiyong Chen <billbill290@gmail.com> (github: UncleBill)
Utkarsh Upadhyay <musically.ut@gmail.com) (github: musically-ut)
Michael Salihi <admin@prestance-informatique.fr> (github: PrestanceDesign)
+ Dahan Gong <gdh1995@qq.com> (github: gdh1995)
Feel free to add real names in addition to GitHub usernames.
diff --git a/background_scripts/bg_utils.coffee b/background_scripts/bg_utils.coffee
index 96c1282a..ca042686 100644
--- a/background_scripts/bg_utils.coffee
+++ b/background_scripts/bg_utils.coffee
@@ -18,6 +18,11 @@ class TabRecency
@deregister removedTabId
@register addedTabId
+ chrome.windows.onFocusChanged.addListener (wnd) =>
+ if wnd != chrome.windows.WINDOW_ID_NONE
+ chrome.tabs.query {windowId: wnd, active: true}, (tabs) =>
+ @register tabs[0].id if tabs[0]
+
register: (tabId) ->
currentTime = new Date()
# Register tabId if it has been visited for at least @timeDelta ms. Tabs which are visited only for a
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index 8b816cd4..bbcd01e7 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -60,6 +60,8 @@ exports.chrome =
onRemoved:
addListener: () -> true
getAll: () -> true
+ onFocusChanged:
+ addListener: () -> true
browserAction:
setBadgeBackgroundColor: ->