WebExtension: Close or tab without history

Is there any way to close a window or tab and not have it listed in the recently closed tabs/windows list, or remove it from the list afterwards?

I need to open some temporary popups that make no sense whatsoever to be re-opened by the user and only result in dead entries in those lists.

The only legit reason I can think of (at the moment) to have temporary popups would be some sort of dialog tabs. They would not make sense or even could be harmful if opened out of the order. It might be good to know what your use case actually is.

As for the remove afterwards aspect you might want to try: browser.tabs.onRemoved and browser.history.deleteUrl. But I doubt that reviewers will appreciate it, if you start to mess with the user’s history just to get rid of some specific Urls.

Better send a dialog tab an activate/token message after one was opened. All users would get, if they opened such an url from the history, would be a disabled dialog.

At the moment, I need that for Wikipedia Peek.

Currently, I am extending it to show little preview boxes on (optionally) every website.
To isolate the content from the page (as good as I think it is possible) I use sandboxed iframes with blob:-URLs for the content.

But that can fail if the CSP of the page restricts the allowed child-srcs.
So if it does, I open popup windows in the corresponding places (and tabs on Android).
At least the former can work pretty well, but it adds dead entries to the tab and window history.

Re-opening these windows/tabs is not harmful for the extension, but it prevents the users from re-opening the windows/tabs they actually want.

This would of course also be fixed if WebExtensions had a proper way of displaying overlay information.

I’m not sure if this will completely meet your needs, but a WebExtensions API for sessions.forgetClosedTab and sessions.forgetClosedWindow is about to land in Nightly. See https://bugzilla.mozilla.org/show_bug.cgi?id=1334266 for status/details.

1 Like

Thanks for the notice!
That looks very promising. An additional argument to tabs/windows.remove() would be somewhat more straight forward for this use case (and many others, I think) and closing a window and then asynchronously asking the browser to forget the most recently closed one (which I think is what the API currently does) sounds like it can introduce race conditions, but I think this will do.