Previous URL of a tab

I want to get the previous URL of a tab.
So if the back button it not greyed out, and you press it, the URL that then appears in the URL bar is the one I want.

Q: Why don’t you use tabs.goBack() ?
A: Because I only want to know the previous URL.
I do not want to change the tab’s URL.

Q: Why do you need this?
A: If a download’s referrer is null, I want to automatically determine a suitable referrer.
In some cases, the current tab’s previous URL is exactly what I want.

Someone has suggested using webNavigation.onCommitted:

I’m using browser.tabs.onRemoved and browser.tabs.onUpdated instead.
Because my extension already has the “tabs” permission, and if I wanted to use webNavigation.onCommitted, I’d have to add another permission.

The attached test extension demonstrates this.

But maybe there’s a better way to do this.
Is there an API where I can get a tab’s previous URL?
I’ve looked at the “history” API, but it doesn’t seem to offer this. (4.2 KB)

I would say the browser.tabs.onUpdated is the best option. It gives you clear info that the URL has changed.
However I’m not sure how well it will work if the page starts to modify the history with the History.replaceState()