Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Navigation History Behavior Across Browsers with Resource URLs Using tabs.update() #677

Closed
mshibanami opened this issue Aug 20, 2024 · 4 comments
Labels
discussion Needs further discussion inconsistency Inconsistent behavior across browsers

Comments

@mshibanami
Copy link

The following code handles navigation history differently across Firefox, Chrome, and Safari, and I'd like to know the expected behavior or whether we have a chance to define the expectation:

chrome.tabs.update(
    tabId,
    { chrome.runtime.getURL("test.html") });

When running the above code:

  • Firefox: Simply handles test.html like a normal web page. After navigating to test.html, the user can go back to the previous page.
  • Chrome: Also handles test.html like a normal web page but removes the previous page from the history if the user hasn't interacted with the previous pages since the tab was created.
  • Safari: Deletes all previous pages from the history, not only the last page. Plus, it doesn't display the URL of test.html in the address bar.

Which one is expected? Or do we have a chance to standardize the behavior across browsers, especially regarding the navigation history?

Demo

This is the demo of creating a new tab with example.com and then opening test.html bundled into the extension.
firefox.mov
chrome.mov
safari.mov
And this is the code I actually used in the above demo.
// Safari and Firefox
chrome.tabs.create({ url: "https://example.com" })
  .then(tab => {
    const tabId = tab.id;
    setTimeout(() => {
      let url = chrome.runtime.getURL("test.html");
      chrome.tabs.update(
        tabId,
        { url });
    }, 1000);
  });

// Chrome
chrome.tabs.create(
  { url: "https://example.com" },
  (tab) => {
    setTimeout(() => {
      let url = chrome.runtime.getURL("test.html");
      chrome.tabs.update(
        tab.id,
        { url });
    }, 3000);
  });

A use case

My Safari extension has a feature of redirecting to another app. Specifically, when the user tries to open a web page, the extension first navigates to a loading page bundled into the extension, and then the extension opens another app by running a native CLI command. However, opening the loading page causes Safari to delete the navigation history, preventing the user from returning to the previous web pages.
Yesterday, I received user feedback about this issue and realized that Firefox's way would work ideally for my extension. Therefore, I hope the browsers will be aligned with what Firefox does.

@dotproto
Copy link
Member

dotproto commented Aug 29, 2024

The behavior described for Chromium matches that engine's general handling of navigations. This behavior is described as a history manipulation intervention and was introduced in 2019. To the best of my knowledge other engines have not implemented this.

EDIT: In today's meeting @Rob--W noted that Firefox also has some history manipulation intervention.

@Rob--W
Copy link
Member

Rob--W commented Aug 29, 2024

EDIT: In today's meeting @Rob--W noted that Firefox also has some history manipulation intervention.

FYI in Firefox it was implemented in https://bugzilla.mozilla.org/show_bug.cgi?id=1515073, with follow-ups in https://bugzilla.mozilla.org/show_bug.cgi?id=1645211

On Firefox's side, our preference is to keep Firefox's current behavior and to allow extensions to replace history entries with the loadReplace option, as suggested in:

According to @xeenon , the disappearance of history items in Safari is a bug.

(see meeting notes for more discussion, pending review in #681).

@Rob--W Rob--W added the inconsistency Inconsistent behavior across browsers label Aug 29, 2024
@xeenon
Copy link
Collaborator

xeenon commented Sep 2, 2024

Thanks! We’re tracking this as a Safari bug rather than a WebKit issue. Bug reference: 134939755

@mshibanami
Copy link
Author

Thanks for the responses! I now understand the differences in browser behavior, and it's good to know related issues are being addressed. I'll close this discussion. Appreciate the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs further discussion inconsistency Inconsistent behavior across browsers
Projects
None yet
Development

No branches or pull requests

4 participants