Skip to content

Navigating to same url - replace or add? #6682

Open
@jakearchibald

Description

@jakearchibald

It seems like:

  • Navigating from /a to /a is treated like a reload (replaces history entry).
  • Navigating from /a to /a#foo is a hash change navigation.
  • Navigating from /a#foo to /a is a full navigation to /a (adds a history entry).

However, replace should only happen if the initiator is same origin to the current document.

There's a non-interoperable case when it comes to redirects:

  1. Navigate to https://redirect-session-history.glitch.me/a - entry1
  2. Navigate to /b which redirects to /a

In this case Chrome & Safari will add a new history entry, whereas Firefox will replace the existing entry (or treat it like a reload, I'm not sure which).

I don't think it matters too much which behaviour we go with, but the Chrome/Safari behaviour seems simpler.

Firefox will switch to 'replace' even if part of the redirect is cross-origin, but I don't think that really matters in this case, because I'm pretty sure it's already observable.

@annevk @domenic @smaug---- this is the case we 'discovered' in the meeting.

Tests

Test:

  1. Navigate to https://redirect-session-history.glitch.me/a - entry1
  2. Navigate to /a

Chrome, Firefox, Safari: replace doc in entry1

Test:

  1. Navigate to https://redirect-session-history.glitch.me/a - entry1
  2. Navigate to /a#foo - entry2
  3. Navigate to /a

Chrome, Firefox: 3 history entries, first two share a document

Safari: 3 buggy history entries. Going back results in no doc change. Going back again results in no doc change, but also no hash change.

Test:

  1. Navigate to https://redirect-session-history.glitch.me/a - entry1
  2. Navigate to /b which redirects to /a

Chrome, Safari: 2 history entries, separate documents
Firefox: replace doc in entry1

Firefox will still replace if the redirect goes via another origin.

Test:

  1. Navigate to https://redirect-session-history.glitch.me/a - entry1
  2. Navigate to /a#foo - entry2
  3. Navigate to /b which redirects to /a

Chrome, Firefox: 3 history entries, first two share a document

Safari: 3 buggy history entries. Going back results in no doc change. Going back again results in no doc change, but also no hash change.

Test:

  1. Nav to https://redirect-session-history.glitch.me/a - entry1
  2. Nav to /a#foo - entry2
  3. Nav to /b which redirects to /a#hello

Chrome, Firefox: Entry 3 has a different doc to entries 1 and 2 (which continue to share a doc).

Safari: 3 buggy history entries. Going back results in no doc change. Going back again results in no doc change, but also no hash change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions