Skip to content

Fully implement HistoryTravesalTaskSource #10994

Open

Activity

  1. added
    A-content/dom
    C-assigned
    on May 3, 2016
  2. KiChjang commented on May 12, 2016

    @KiChjang
    Contributor

    Also part of #7959.

  3. KiChjang commented on May 12, 2016

    @KiChjang
    Contributor

    @stjepang Did you say that you were working on this?

  4. removed
    C-assigned
    on Jan 27, 2017
  5. cbrewster commented on Jan 27, 2017

    @cbrewster
    ContributorAuthor

    We should be queuing tasks to the HistoryTraversalTaskSource instead of directly sending messages to the constellation when traversing the history via the history API.

    https://html.spec.whatwg.org/multipage/browsers.html#traverse-the-history-by-a-delta

  6. nox commented on Oct 2, 2017

    @nox
    Contributor

    Was this done in the end?

  7. jdm commented on Oct 2, 2017

    @jdm
    Member

    No.

  8. vimpunk commented on Nov 10, 2018

    @vimpunk
    Contributor

    What is the status of this issue? I'd be interested in working on it but I might need some help.

  9. vimpunk commented on Nov 11, 2018

    @vimpunk
    Contributor

    Started looking into this and for sure, HistoryTraversalTaskSource does not implement TaskSource. What were the reasons or difficulties that prevented this?

  10. vimpunk commented on Nov 11, 2018

    @vimpunk
    Contributor

    #21804 (comment)

    Hmm, it looks like this may not be relevant after all?

  11. gterzian commented on Dec 1, 2018

    @gterzian
    Member

    @mandreyel I think there might still be something to do on this one.

    HistoryTraversalTaskSource was recently fully implemented at 14bc8ab, and it's not actually used anywhere yet.

    Key is the difference between these two related concepts:

    1. A #session-history-traversal-queue,
    2. A #history-traversal-task-source

    The "session-history-traversal-queue" is a concept that I think would belong in the constellation, and is currently implemented indeed "by sending a message to the constellation", I think from there

    fn traverse_history(&self, direction: TraversalDirection) -> ErrorResult {

    The "history-traversal-task-source" is something that belongs in the script-thread like the other task sources and can be used to enqueue tasks on the script event-loop running inside a script-thread.

    This last part is currently not used.

    What is happening instead is:

    1. The TraverseHistoryMsg is sent, corresponding to Step 1 of https://html.spec.whatwg.org/multipage/history.html#traverse-the-history-by-a-delta " append a task to this top-level browsing context's session history traversal queue".
    2. the message is handled by the constellation here:
      fn handle_traverse_history_msg(
      (We could consider this the "session-history-event-loop")
    3. The constellation then does "a whole bunch of stuff", among others, sending a UpdateHistoryState back to the script-thread.
    4. As part of handling the message, the script-thread will run the history-traversal algorithm. This is actually Step 5.3 of traverse-the-history-by-a-delta.

    So, I think that what is missing is doing Step 5 of traverse-the-history-by-a-delta, inside a task from the "history-traversal-task-source".

    The change that can be made is in 3 above(script-thread handling the message from constellation), we should instead of calling the history API directly, enqueue a task on the history traversal task source, and this task should consist of running the various substeps of Step 5 at https://html.spec.whatwg.org/multipage/history.html#traverse-the-history-by-a-delta

    The main benefit of queuing a task in response to receiving a message from the constellation, as opposed to running the history changes directly in response to the message, is that queuing a task will ensure some sort of sane interleaved executing of the task in the context of all other history tasks that might have been(or will be) enqueued, which could actually be relevant for some edge cases(you can read more about this at https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-for-spec-authors, in this case the stuff happening in the constellation is done "in parallel", and the final changes to the history inside a script-thread is done "on the event-loop").

    Other changes that might be necessary is implementing Step 4.1 of https://html.spec.whatwg.org/multipage/browsing-the-web.html#history-traversal "Remove any tasks queued by the history traversal task source that are associated with any Document objects in the top-level browsing context's document family."

    Additionally, we could also consider refactoring the code so as to more explicitly implement a session-history-event-loop inside the constellation(or maybe just add a comment with a link to the spec somewhere)

  12. added
    A-navigation
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domA-navigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions