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:

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)

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:
Thoughts?
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:
Let's analyze both cases:
entry-updateentry-updatedfn. 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 forentry-updatelooks like this:reloadreload'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 entryI 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:
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.Thoughts?