Skip to content

Updating the session history seems pretty broken #6197

Description

@domfarolino

Earlier this week I noticed that we don't always set a Window's associated Document (via setting the browsing context's active document) right away after creating the Window, which can lead to some weird problems. While going down this rabbit hole and discussing this more with @domenic I realized that the following flow is pretty broken:

While trying to figure out the best way to fix this, I think the idea is that we need to plumb in the correct "new document" to the #update-the-session-history-with-the-new-page algorithm so that we can appropriately reference it in Step 1, instead of accidentally referencing the old document.

However even once we fix this, from talking with Domenic I think we still have the following problem:

Let’s analyze the two conditionals in #update-the-session-history-with-the-new-page below:


Screen Shot 2020-12-05 at 14 21 35

Let's analyze both cases:

  • entry-update

    • The spec text matches the entry-update dfn. The dfn says that we won’t be creating a new session history entry, but instead will update the existing current entry with a brand new document, and traverse to this current entry. However I am not sure how this is actually supposed to work. The flow for entry-update looks like this:
      • #traverse-the-history(document = null) => #navigate => #navigate-html
        • create and initialize a document
        • #update-the-session-history[...] (triggering the above screenshot text)
          • Sets current entry's document to the newly-created document
          • #traverse-the-history > Step 5 always evaluates false; we never activate the new document
    • I propose that we change the dfn and the spec text here to create a new session history entry, set it up with the new document etc. Then we put the new entry in the session history where current entry is. Now current entry holds an old entry that is no longer in the session history and is about to be deleted. Continue to #traverse-the-history passing in the new entry (not current entry). Step 5 evaluates to true, and we can activate the new document!
  • reload

    • The spec text here DOES NOT match what the reload's dfn says. The dfn states that we'll reload the current entry's document by: creating a brand new history entry, putting it in place of the current entry (_which from my understanding doesn't actually change current entry’s value), and navigating to the new entry
    • In other words, it expects my proposal above (I think)

Screen Shot 2020-12-05 at 14 21 43

I don’t think this is doing the right thing. I first read this as if it were setting current entry to a new session history entry, and then traversing the history to it. However after talking to Domenic I think it's doing something different, but equally wrong: Putting a new entry in the session history where current entry is (current entry's value hasn't changed), and invoking traverse-the-history with current entry. I think it should invoke #traverse-the-history with the new entry, so that #traverse-the-history > step 5 actually compares the two distinct entries. Does that make sense?


If my analysis is right, then I think to fix all of these there are the following action items:

  • Change the signature of #update-the-session-history-with-the-new-page to explicitly take a new Document
  • Plumb the new document to all call sites of this algorithm
  • Have step 1 reference this new Document, instead of the "old" one that is currently activated
  • Optional: Decouple the two concepts (a) browsing context's active document, and (b) Window's associated Document`, so that we can set a Window's associated Document ASAP, without setting the browsing context's active document.
  • Change the first conditional branch of #update-the-session-history-with-the-new-page > step 3 to my proposal above
  • Change the second conditional branch of #update-the-session-history-with-the-new-page > step 3 to the other proposal above (that is, mostly leave it as-is and invoke #traverse-the-history with the new entry, instead of current entry.

Thoughts?

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions