Skip to content

Conversation

@TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented Aug 20, 2018

The current behavior of adding a new entry to the session history is removed, with the replace parameter behavior made the only option. To fix #3885, we now reuse history.replaceState()'s history model, which keeps the document's URL and the history entry URL in sync.

At the same time, we restrict the history state update (including setting the document's URL) to be only run with fully active documents. Firefox already bails out for non-fully active documents (including those that are active documents), and it's not expected that there would be much usage of the URL of non-fully active documents anyway.

This allows us to additionally remove the seldom implemented replace parameter in document.open(), whose behavior is now the default (aligning with with Chrome and Safari). The IDL is modified accordingly.

This PR also removes the "overridden reload" algorithm and related concepts, which were previously only implemented in Firefox and Edge, causing developer confusion evident in https://bugzilla.mozilla.org/show_bug.cgi?id=556002.

Tests: web-platform-tests/wpt#12555
Tests: web-platform-tests/wpt#12634
Tests: web-platform-tests/wpt#12636
Tests: web-platform-tests/wpt#12650

Fixes #3564.
Fixes #3885.


/browsing-the-web.html ( diff )
/custom-elements.html ( diff )
/dom.html ( diff )
/dynamic-markup-insertion.html ( diff )
/history.html ( diff )
/infrastructure.html ( diff )
/origin.html ( diff )
/parsing.html ( diff )
/webappapis.html ( diff )

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it was my understanding that Chrome and Safari don't alter history at all for this method. Should we really go there? Yes, see #3885.


</ol>


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it removes too many newlines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? There are still two newlines remaining here (the first one is above this hunk).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there used to be three, unless I'm missing something. Perhaps two is more consistent with content I can't see in this diff though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's little consistency within the spec and I see places with one, two, three, or four consecutive empty lines. However I think two seems to remain the most popular for the sections surround this one…

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some things to tweak!

<p class="note">An <span data-x="override URL">override URL</span> is set when <span
data-x="javascript protocol">dereferencing a <code>javascript:</code> URL</span> and when
performing <span>an overridden reload</span>.</p>
<p><dfn data-x="set the document's address">Setting the document's address</dfn>: Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe as a follow-up, I hope we can move this into "Initializing a new Document object", and use something actually concrete instead of "the URL that was originally to be fetched". (Especially since that seems to imply the request URL, not the response URL, which can't be right?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3953.

<p>Add a <span>session history entry</span> entry to the session history, after the
<span>current entry</span>, with</p>

<ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<ul class="brief"> (with no <p>s) or <dl>, maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that but decided the current style looked slightly better…

<p>Add a <span>session history entry</span> entry to the session history, after the
<span>current entry</span>, with</p>

<ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah, I really wish entries were proper structs with fields.

source Outdated

<hr id="history-1">

<p>The <dfn>history state update steps</dfn>, given a <code>Document</code> object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned the use of "state" here is a bit too narrow. Also this doesn't communicate how we ideally only want to change the document URL via this algorithm. Maybe something like "URL and history update steps"?

source Outdated

// <span>dynamic markup insertion</span>
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type, optional DOMString replace = ""); // type is ignored
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type, optional DOMString replace); // both type and replace are ignored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change the name of the arguments to e.g. unused1, unused2, or historical1, historical2. This will involve changing all the references throughout the document, sad to say.

We should update the note that says "The type argument is ignored" to explain that both are ignored, but that we can't remove the arguments because it would affect Web IDL overload resolution for historical code, causing it to throw. With a link to whatwg/webidl#581.

And we should link this IDL comment to that note.

source Outdated
<li><p>If <var>document</var> is <span>fully active</span>, then run the <span>history state
update steps</span> with <var>document</var> and the <span
data-x="concept-document-url">URL</span> of the <span>responsible document</span> specified by
the <span>entry settings object</span>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we save the "responsible document" in a variable earlier, since it's used twice?

source Outdated
@@ -90985,14 +90971,6 @@
<li><p>Remove any earlier entries whose <code>Document</code> object is
<var>document</var>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas why this still shows up in the diff, despite previous commits removing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, it was removed in this PR.

source Outdated
If the user <span>refused to allow the document to be unloaded</span>, then return. Otherwise,
the <span>insertion point</span> will point at just before the end of the (empty) <span>input
<li><p>Run the <span>document open steps</span> with <var>document</var>. If the user
<span>refused to allow the document to be unloaded</span>, then return. Otherwise, the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we forget to clean this up previously? We don't unload any more.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits!

source Outdated
<span>completely loaded</span>.</p>
<p class="note">The <code data-x="dom-document-open">document.open()</code> method does not affect
whether a <code>Document</code> is <span>ready for post-load tasks</span> or <span>completely
loaded</span>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While here, let's move this note up and have it talk about the document open steps?

source Outdated
<span>current entry</span>, with</p>

<ul>
<li><p><var>newURL</var> as the <span>URL</span></p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for such lists they should be semicolon-delimited, with a period at the end. I.e. they're a part of one big sentence. (Which, yes, is split over several "paragraphs".)

@TimothyGu TimothyGu added the needs tests Moving the issue forward requires someone to write tests label Aug 23, 2018
@TimothyGu TimothyGu removed the needs tests Moving the issue forward requires someone to write tests label Aug 23, 2018
@TimothyGu TimothyGu force-pushed the document-open-s2 branch 3 times, most recently from 5c865f5 to c241269 Compare August 23, 2018 18:31
Or: document.open() simplifications, part 1.9.

This behavior is only implemented in Firefox and Edge and has
contributed to developer confusion. See
https://bugzilla.mozilla.org/show_bug.cgi?id=556002.

This is a part of the effort to renovate document.open(). See
whatwg#3818 for context.

Tests: web-platform-tests/wpt#12555
The resultant URL and history state update steps will be used in
document.open().
The current behavior of adding a new entry to the session history is
removed, with the "replace" parameter behavior made the only option. To
fix whatwg#3885, we now reuse history.replaceState()'s history model, which
keeps the document's URL and the history entry URL in sync.

At the same time, we restrict the history state update (including
setting the document's URL) to be only run with fully active documents.
Firefox already bails out for non-fully active documents (including
those that are active documents), and it's not expected that there would
be much usage of the URL of non-fully active documents anyway.

This allows us to additionally remove the seldom implemented "replace"
parameter in document.open(), whose behavior is now the default
(aligning with with Chrome and Safari). The IDL is modified accordingly.

Tests: web-platform-tests/wpt#12555
Tests: web-platform-tests/wpt#12634
Tests: web-platform-tests/wpt#12636
Tests: web-platform-tests/wpt#12650

Fixes whatwg#3564.
Fixes whatwg#3885.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

document.open() can make a document's URL go out of sync with its history entry At least Blink does not support document.open()'s replace parameter

3 participants