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

At least Blink does not support document.open()'s replace parameter #3564

Closed
domenic opened this issue Mar 14, 2018 · 6 comments · Fixed by #3946
Closed

At least Blink does not support document.open()'s replace parameter #3564

domenic opened this issue Mar 14, 2018 · 6 comments · Fixed by #3946
Labels
interop Implementations are not interoperable with each other topic: document.open() topic: history

Comments

@domenic
Copy link
Member

domenic commented Mar 14, 2018

See https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/Document.cpp?l=3131&rcl=ebf30557b76f27757dbdaa1a03e7104fd7ce29c5

We should investigate other browsers, and perhaps remove this functionality, as we're doing with the type parameter in #3559. Or, file a bug on Blink to implement it, if they're the odd one out.

@domenic domenic added the interop Implementations are not interoperable with each other label Mar 14, 2018
annevk added a commit that referenced this issue Mar 14, 2018
Chrome, Edge, and Safari don't implement it and this is considered a legacy method.

Follow-ups: #3564 and #3565.

Tests: web-platform-tests/wpt#9978.

Fixes #3546.
@domfarolino
Copy link
Member

domfarolino commented Mar 15, 2018

Seems that Firefox supports it (see https://searchfox.org/mozilla-central/source/dom/html/nsHTMLDocument.cpp#1181) but that it doesn't work properly (see this legacy bug https://bugzilla.mozilla.org/show_bug.cgi?id=264403). Though given the list of open document.open Bugzilla issues, it seems there's always been at least some problems with it.

Edit:

I can check Safari later today. What about Edge?

@annevk
Copy link
Member

annevk commented Mar 15, 2018

How do you test this? This

<iframe></iframe><script>
onload = () => { 
  var d = document.getElementsByTagName('iframe')[0].contentDocument;
  d.open();
  d.write("hi");
  d.close();
  history.back();
};
</script>

gives rather inconsistent results for me. Supposedly per the specification if replace is not set you always add a history entry, so history.back() would restore the previous document in the <iframe>, but nobody does that.

@domfarolino
Copy link
Member

domfarolino commented Mar 19, 2018

Oops, forgot to report or Safari. The behavior of document.open in Safari did not seem to be affected by the replace parameter (see later). @annevk I (perhaps incorrectly?) tested this in the DevTools just seeing if I could history.back()/forward() after opening/closing the document (with and without the "replace" second param).

@annevk
Copy link
Member

annevk commented Mar 20, 2018

In Chrome, when I navigate to http://example.com/, open the console, document.open(), document.write("test"), document.close(), history.back(), I end up on chrome://newtab. That means it does effectively replace the current entry, no?

That is, history is not meddled with at all.

And I think the only reason to support history of sorts here is to have Firefox's infrastructure (by making it create a new global), which means this is probably a soft duplicate of #1698.

@domfarolino
Copy link
Member

Yeah in Chrome, the history of the created document seems to inherit that of the preceding one. So the current entry is always replaced, with or without the "replace" parameter. Actually in Firefox it seems to work properly from my testing? Safari also seems to replace by default, disallowing history.back() to take you to the page that called document.open() (no "replace").

@annevk
Copy link
Member

annevk commented Mar 21, 2018

Yeah, because Firefox has a fundamentally different architecture.

Last I talked to bz about this he seemed somewhat open to adopting the architecture of other browsers for document.open(), provided it had sufficient tests and their model was actually clear. Given the things we're discovering here their model might not be all that complex.

annevk added a commit that referenced this issue Apr 27, 2018
For #1698, #3564, ... Needs many tests.
annevk added a commit that referenced this issue May 2, 2018
For #1698, #3564, ... Needs many tests.
annevk added a commit that referenced this issue May 3, 2018
For #1698, #3564, ... Needs many tests.
annevk added a commit that referenced this issue May 3, 2018
For #1698, #3564, ... Needs many tests.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 20, 2018
The current session history handling is removed and replaced by a
simpler history.replaceState-based model. This also removes the seldom
implemented "replace" parameter in document.open(), and converge with
Chrome and Safari by always replacing.

Tests: ...

Fixes whatwg#3564.
Fixes whatwg#3885.
TimothyGu added a commit to TimothyGu/html that referenced this issue 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 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.

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: … (more coming soon)

Fixes whatwg#3564.
Fixes whatwg#3885.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 21, 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 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.

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: … (more coming soon)

Fixes whatwg#3564.
Fixes whatwg#3885.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 23, 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 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.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 23, 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 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.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 23, 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 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.
TimothyGu added a commit to TimothyGu/html that referenced this issue Aug 23, 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 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 pushed a commit that referenced this issue Aug 23, 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.

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.
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
Chrome, Edge, and Safari don't implement it and this is considered a legacy method.

Follow-ups: whatwg#3564 and whatwg#3565.

Tests: web-platform-tests/wpt#9978.

Fixes whatwg#3546.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
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.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
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
Labels
interop Implementations are not interoperable with each other topic: document.open() topic: history
Development

Successfully merging a pull request may close this issue.

4 participants