Find/restore closed tab by Tab ID


(rugk) #1

I had to find out that I cannot actually restore tabs by their tab ID.

So let’s say I got the tab ID from somewhere else and want to check, whether this tab has recently been closed (and restore it, if it is so). Actually; as far as I see, this is not possible currently.

getRecentlyClosed returns list of closed tabs, using the standard tab object. However – and this is currently not documented (hint: maybe someone could improve it) – it does not include the tab ID (i.e. tab.id), it only includes the sessionId, which again, is not included in the “usual” tab object, when you get it via other methods when the tab is still open.

So basically yopu have two identifiers for the same/identical object (be it in a closed or “opened” state), which are mutually exclusive: You get one ID only when the tab is closed and the other only when it is opened. Thus, you have no way to correctly associate them in any good fashion.
(I know you could work around that by maybe trying to match URL and tab title, but this is not only a hackish workaround, but may actually lead to miss-associations and in the end results possibly restoring the wrong tab.)


So an actual nice solution would be, if you could just expose the id in the tab object returned by the “recently closed tabs”.