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 steps and quirks mode #3831

Closed
TimothyGu opened this issue Jul 19, 2018 · 8 comments
Closed

Document open steps and quirks mode #3831

TimothyGu opened this issue Jul 19, 2018 · 8 comments
Labels
interop Implementations are not interoperable with each other topic: document.open()

Comments

@TimothyGu
Copy link
Member

TimothyGu commented Jul 19, 2018

Currently, Chrome, Edge, and Safari all set the mode of the current document that's being processed through document open steps to no-quirks mode. Firefox does not, however.

The current call to set mode to no-quirks in WebKit was from https://bugs.webkit.org/show_bug.cgi?id=44788, but it's possible that the behavior has been there since even before that patch. I cannot find a corresponding call in the HTML Standard from that era.

Tests I used to confirm this: https://github.com/TimothyGu/document-open-tests (the ones starting with step-undef-no-quirk)

WPT (still being worked on): web-platform-tests/wpt#10679

@TimothyGu TimothyGu added interop Implementations are not interoperable with each other topic: document.open() labels Jul 19, 2018
@TimothyGu
Copy link
Member Author

It seems like the clearest path forward is to align with three out of four browsers and set to no-quirks.

@annevk
Copy link
Member

annevk commented Jul 26, 2018

Yeah, the main weird thing is that this means it can change dynamically. I think we should add another test that stresses that somehow, by looking at CSS rendering of a DOM-inserted element as well rather than just document.compatMode.

@bzbarsky @hsivonen can you see any problems about changing this in Firefox? (Other than perhaps not wanting to piecemeal align document.open() with other browsers and doing it all in one go.)

@TimothyGu
Copy link
Member Author

Yeah, the main weird thing is that this means it can change dynamically.

Hmm, can't it already change dynamically due to document.write()?

@bzbarsky
Copy link
Contributor

So the point is that when you open() non-Gecko browsers set no-quirks mode (and is it no-quirks or is it limited-quirks? Needs a layout test to tell.) but as soon as you write() non-witespace they recompute the mode?

I guess what Gecko does is that we leave whatever the mode was when open() happens, then reset it when the first non-whitespace write() happens (this second part all browsers do interoperably)?

If that's the situation, then aligning with the other browsers on what happens when open() is called seems OK to me.

@TimothyGu
Copy link
Member Author

@bzbarsky You are right in that I should check if it's limited-quirks or no-quirks. From source code inspection WebKit/Blink does no-quirks, but I'm not sure about Edge currently. Could you point to some literature that shows how they differ?

but as soon as you write() non-witespace they recompute the mode?

I guess what Gecko does is that we leave whatever the mode was when open() happens, then reset it when the first non-whitespace write() happens (this second part all browsers do interoperably)?

Precisely.

@bzbarsky
Copy link
Contributor

Could you point to some literature that shows how they differ?

I think the only difference is the handling of this testcase:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en">
<body>
  <div style="border: 1px solid black; float: left; background: red">
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAUCAYAAAB7wJiVAAAASklEQVRYhe3RoRHAQBDEsOu/6YR+B2sgIO4Z3919pMwDMCRtHoAhafMADEmbB2BI2jwAQ9LmARiSNg/AkLR5AIakzQMwJG0ewOMHVxvImgCzjX4AAAAASUVORK5CYII=">
  </div>
</body>

which has a red bar under the black rectangle in no-quirks mode but not in quirks or limited-quirks.

@bzbarsky
Copy link
Contributor

Though there might be something weird about <br> too... I can't tell without paging in more about the line layout code than I really want to right now.

@TimothyGu
Copy link
Member Author

TimothyGu commented Jul 28, 2018

@bzbarsky Found https://quirks.spec.whatwg.org/ and corresponding tests… Thanks!

Tests (web-platform-tests/wpt#10679) have been updated to account for limited-quirks. Chrome and Safari always use no-quirks. Haven't been able to check Edge, but from talking to their engineers I'm convinced that they also use no-quirks.

@annevk annevk closed this as completed in 7d21798 Aug 28, 2018
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
Per investigation in whatwg#3818, this change aligns the behavior of
document.open() with Chrome and Safari.

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

Closes whatwg#3831.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
Per investigation in whatwg#3818, this change aligns the behavior of
document.open() with Chrome and Safari.

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

Closes whatwg#3831.
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()
Development

No branches or pull requests

3 participants