Hi all!
I'm seeing an issue with the Back button when an extension opens new URLs.
Here's the scenario:
1. User has a single tab open to page A.
2. Extension calls chrome.tabs.update(tab_id, { url }) to open pages B, then C, then D. (This is over time, as part of a workflow.)
3. User clicks Back button.
4. Browser returns to page A, not page C.
However, if while page B was open, the user had clicked anywhere on the page, the Back button would return to page B.
Interestingly, if instead the user *right-clicks* the Back button, ALL the pages are visible starting with the most recent, e.g. C, B, A.
Therefore, it appears that if the extension opens a page, but the user doesn't interact with that page, it becomes part of the right-click history on the Back button, but not part of the history when (left-)clicking the Back button.
In addition to chrome.tabs.update(), I've also tried sending a message to a content script in the tab, which in turn calls `window.location.href = url`, but this has the same behavior as above.
On MDN, tabs.update() has an option for `loadReplace`[1]. It sounds like the behavior I want is `chrome.tabs.update(tab_id, { url, loadReplace: false })`. However, loadReplace does not exist in Chrome, and I haven't tried it on Firefox.
Chrome's behavior isn't exactly `loadReplace: true` nor `loadReplace: false` since interaction with a page seems to change the behavior.
Anyone else run into this issue, or recommend any workarounds?
Best wishes,
Richard
[1]
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/update