Skip to content

Which location should reload on history.go(0)? #2436

Closed

Description

@asajeffrey

The spec for history.go() at https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go says:

When the go(delta) method is invoked, if delta is zero, the user agent must act as if the location.reload() method was called instead.

This is ambiguous as to which location should be used, the one for the window whose history is being accessed, or the current document. Unfortunately, different browsers behave differently, as shown by:

<html>
  <body>
    <iframe id="child"></iframe>
  </body>
  <script>
    var child = document.getElementById("child");
    setTimeout(function () { console.log("Finished."); }, 1000);
    child.contentWindow.history.go(0);
  </script>
</html>

Under FF, this will loop forever reloading (because the main document is reloaded) whereas in Chrome it will terminate (because the child is reloaded).

Activity

  1. asajeffrey commented on Mar 14, 2017

    @asajeffrey
    Author
  2. asajeffrey commented on Mar 14, 2017

    @asajeffrey
    Author

    IRC chat on #servo with @KiChjang and @bzbarsky: http://logs.glob.uno/?c=mozilla%23servo&s=14+Mar+2017&e=14+Mar+2017#c630800

    "The problem is that if you call childWindow.go(0), what if you are same-origin with the child, but x-origin with the parent?"

  3. annevk commented on Mar 15, 2017

    @annevk
    Member

    This basically depends on #1454 being fixed I think.

  4. asajeffrey commented on Mar 15, 2017

    @asajeffrey
    Author

    Well it's related to #1454, but orthogonal. Currently the spec special-cases history.go(0), it's the only history traversal that reloads documents that haven't been discarded.

  5. annevk commented on Mar 16, 2017

    @annevk
    Member

    But making history more of a flat concept should help a lot with deciding what to reload I think.

  6. annevk commented on May 4, 2017

    @annevk
    Member

    This is also related to #2018 (should history return cross-origin information).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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