Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.open() simplifications, part 2 #3946

Merged
merged 4 commits into from Aug 23, 2018

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
@@ -80542,6 +80542,85 @@ interface <dfn>History</dfn> {

<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
@@ -9168,7 +9168,7 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {
readonly attribute <span>HTMLOrSVGScriptElement</span>? <span data-x="dom-document-currentScript">currentScript</span>; // classic scripts in a document tree only

// <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 @@ document.body.appendChild(frame)</code></pre>
<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 added a commit to web-platform-tests/wpt that referenced this pull request Aug 22, 2018
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 22, 2018
For whatwg/html#3946.

Adapts the basic test in
#10817 for a number of
advanced scenarios.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 23, 2018
No browser currently passes the 010.html test, and it is now removed.

For whatwg/html#3946.
@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.
@domenic domenic merged commit 288fc16 into whatwg:master Aug 23, 2018
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 23, 2018
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 23, 2018
For whatwg/html#3946.

Adapts the basic test in
#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 23, 2018
@TimothyGu TimothyGu deleted the document-open-s2 branch August 23, 2018 20:21
zcorpan pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 27, 2018
zcorpan pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 27, 2018
For whatwg/html#3946.

Adapts the basic test in
#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
zcorpan pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 27, 2018
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 28, 2018
The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Aug 28, 2018
The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 29, 2018
…only

Automatic update from web-platform-testsHTML: document.open() and reload (#12555)

For whatwg/html#3946.
--

wpt-commits: 8b0c29bfa35d03c3db9027af796abcdb08b7c6dc
wpt-pr: 12555
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 29, 2018
…, a=testonly

Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636)

For whatwg/html#3946.

Adapts the basic test in
web-platform-tests/wpt#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
--

wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483
wpt-pr: 12636
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 29, 2018
…ocument.open(), a=testonly

Automatic update from web-platform-testsHTML: add test for history.state after document.open() (#12650)

For whatwg/html#3946.
--

wpt-commits: e57d136af9eef24a9f3b54dffcf9c7ca74331f09
wpt-pr: 12650
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 29, 2018
…only

Automatic update from web-platform-testsHTML: document.open() and reload (#12555)

For whatwg/html#3946.
--

wpt-commits: 8b0c29bfa35d03c3db9027af796abcdb08b7c6dc
wpt-pr: 12555
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 29, 2018
…, a=testonly

Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636)

For whatwg/html#3946.

Adapts the basic test in
web-platform-tests/wpt#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
--

wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483
wpt-pr: 12636
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 29, 2018
…ocument.open(), a=testonly

Automatic update from web-platform-testsHTML: add test for history.state after document.open() (#12650)

For whatwg/html#3946.
--

wpt-commits: e57d136af9eef24a9f3b54dffcf9c7ca74331f09
wpt-pr: 12650
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 5, 2018
…creation, a=testonly

Automatic update from web-platform-testsHTML: document.open() and history entry creation (#12724)

The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
--

wpt-commits: f23bb9e37fdf694021519b0e7ce2c282fa026ea5
wpt-pr: 12724
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Sep 5, 2018
…creation, a=testonly

Automatic update from web-platform-testsHTML: document.open() and history entry creation (#12724)

The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
--

wpt-commits: f23bb9e37fdf694021519b0e7ce2c282fa026ea5
wpt-pr: 12724
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…only

Automatic update from web-platform-testsHTML: document.open() and reload (#12555)

For whatwg/html#3946.
--

wpt-commits: 8b0c29bfa35d03c3db9027af796abcdb08b7c6dc
wpt-pr: 12555

UltraBlame original commit: 2e120ceb2b8b1c22b178afaa22ed6d418cab9770
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…, a=testonly

Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636)

For whatwg/html#3946.

Adapts the basic test in
web-platform-tests/wpt#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevkannevk.nl>
--

wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483
wpt-pr: 12636

UltraBlame original commit: 0aaff791b401b17dd832464bc94688c474a08ebc
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…ocument.open(), a=testonly

Automatic update from web-platform-testsHTML: add test for history.state after document.open() (#12650)

For whatwg/html#3946.
--

wpt-commits: e57d136af9eef24a9f3b54dffcf9c7ca74331f09
wpt-pr: 12650

UltraBlame original commit: 33593424f5016a2a7dae3460c0e6c791e9aaa7a7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…creation, a=testonly

Automatic update from web-platform-testsHTML: document.open() and history entry creation (#12724)

The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
--

wpt-commits: f23bb9e37fdf694021519b0e7ce2c282fa026ea5
wpt-pr: 12724

UltraBlame original commit: 3296434f41a427cd1ba5309c5d40eb3b383d0431
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…only

Automatic update from web-platform-testsHTML: document.open() and reload (#12555)

For whatwg/html#3946.
--

wpt-commits: 8b0c29bfa35d03c3db9027af796abcdb08b7c6dc
wpt-pr: 12555

UltraBlame original commit: 2e120ceb2b8b1c22b178afaa22ed6d418cab9770
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…, a=testonly

Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636)

For whatwg/html#3946.

Adapts the basic test in
web-platform-tests/wpt#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevkannevk.nl>
--

wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483
wpt-pr: 12636

UltraBlame original commit: 0aaff791b401b17dd832464bc94688c474a08ebc
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…ocument.open(), a=testonly

Automatic update from web-platform-testsHTML: add test for history.state after document.open() (#12650)

For whatwg/html#3946.
--

wpt-commits: e57d136af9eef24a9f3b54dffcf9c7ca74331f09
wpt-pr: 12650

UltraBlame original commit: 33593424f5016a2a7dae3460c0e6c791e9aaa7a7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…creation, a=testonly

Automatic update from web-platform-testsHTML: document.open() and history entry creation (#12724)

The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
--

wpt-commits: f23bb9e37fdf694021519b0e7ce2c282fa026ea5
wpt-pr: 12724

UltraBlame original commit: 3296434f41a427cd1ba5309c5d40eb3b383d0431
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…only

Automatic update from web-platform-testsHTML: document.open() and reload (#12555)

For whatwg/html#3946.
--

wpt-commits: 8b0c29bfa35d03c3db9027af796abcdb08b7c6dc
wpt-pr: 12555

UltraBlame original commit: 2e120ceb2b8b1c22b178afaa22ed6d418cab9770
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…, a=testonly

Automatic update from web-platform-testsHTML: document.open() and document's URL (#12636)

For whatwg/html#3946.

Adapts the basic test in
web-platform-tests/wpt#10817 for a number of
advanced scenarios regarding document activity.

Co-authored-by: Anne van Kesteren <annevkannevk.nl>
--

wpt-commits: 312d71258a26bfa420f7eef100df4ef92d961483
wpt-pr: 12636

UltraBlame original commit: 0aaff791b401b17dd832464bc94688c474a08ebc
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…ocument.open(), a=testonly

Automatic update from web-platform-testsHTML: add test for history.state after document.open() (#12650)

For whatwg/html#3946.
--

wpt-commits: e57d136af9eef24a9f3b54dffcf9c7ca74331f09
wpt-pr: 12650

UltraBlame original commit: 33593424f5016a2a7dae3460c0e6c791e9aaa7a7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…creation, a=testonly

Automatic update from web-platform-testsHTML: document.open() and history entry creation (#12724)

The 010.html test has been removed for a multitude of reasons:

- It does not seem to work as intended in any browser. (I.e., no browser
  passes the test.)
- The concept it allegedly tests (salvageability) is no longer in the
  specification for document.open().

For whatwg/html#3946.
--

wpt-commits: f23bb9e37fdf694021519b0e7ce2c282fa026ea5
wpt-pr: 12724

UltraBlame original commit: 3296434f41a427cd1ba5309c5d40eb3b383d0431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants