Tab.lastAccessed becomes undefined when the tab is discarded

138 views
Skip to first unread message

Moe Bazzi

unread,
Apr 15, 2024, 6:32:08 AMApr 15
to Chromium Extensions
They Tab.lastAccessed property is great for keeping a track of the tab activation history, for example, great for my chrome extension related to tab navigation. However, it seems that there is something holding it back, and that is when the tab is discarded, it's lastAccessed property gets set back to undefined. In this case, I know the tab is supposed to be thought of as "replaced" (hence, a onReplaced event gets called for it which also changes its tab id), but is wiping the lastAccessed property really the best behavior for the tab API?

This forces me to have to store my own copy of the tab activation history state, which is what I thought the Tab.lastAccessed property would be useful for. Would love to hear the opinions of other developers and the extensions team, thanks :)

wOxxOm

unread,
Apr 15, 2024, 9:52:42 PMApr 15
to Chromium Extensions, Moe Bazzi
Sounds like a bug. Apparently when discarding a tab the browser preserves only an explicitly defined subset of tab properties and lastAccessed wasn't added when it was implemented. If this isn't already reported you can report it in https://crbug.com with a sample extension attached.

Moe Bazzi

unread,
Apr 16, 2024, 12:35:09 PMApr 16
to wOxxOm, Chromium Extensions
Thanks for letting me know! Were you able to find the Chromium source code that handles this? Would love to include that in the bug report, thanks.

wOxxOm

unread,
Apr 16, 2024, 12:59:32 PMApr 16
to Chromium Extensions, Moe Bazzi, Chromium Extensions, wOxxOm
Judging by the source code it is explicitly not included in the tab parameter supplied to event listener such as chrome.action.onClicked, chrome.tabs.onUpdated, chrome.tabs.onCreated, chrome.sessions, chrome.contextMenus. It's unclear why and it's not documented apparently. See if chrome.tabs.get(tabId) adds this info.

Moe Bazzi

unread,
Apr 16, 2024, 3:22:54 PMApr 16
to wOxxOm, Chromium Extensions
I tried reproducing the issue but it doesn't seem to be the case anymore. I could have sworn I was able to reproduce it when I initially reported the issue. I will keep my eye out.
Reply all
Reply to author
Forward
0 new messages