The code: </><!doctype html> or </x><!doctype html> makes Webkit to render page in standards mode (CSS1Compat). According to HTML5 spec: "Documents must consist of the following parts, in the given order: 1. Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character. 2. Any number of comments and space characters. 3. A DOCTYPE." Only BOM, comments and space characters are allowed before DOCTYPE. Steps to reproduce: 1) Go to a page: http://software.hixie.ch/utilities/js/live-dom-viewer/?%20%3C%2F%3E%3C!doctype%20html%3E%0A and notice "CSS1Compat" in log section. Expected result: BackCompat in log section Current result: CSS1Compat in log section
The spec mandates that we render this document standards mode. Our current behavior is correct.
As far as I can tell anything but whitespace, comments, and DOCTYPEs throws you out of the "initial" insertion mode and puts the document in standards mode so if this bug still applies with the new parser there is a bug. (And a lack of tests :/)
I meant to say puts the document in quirks mode. Argh.
Ok. I'll take another look.
Looking now.
Looks like our behavior is correct. Adding tests.
Created attachment 67494 [details] Patch
Comment on attachment 67494 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=67494&action=prettypatch Better to have it say PASS or FAIL, but this is OK.
PASS/FAIL tests are hard to change latter if we're intentionally changing behavior.
Comment on attachment 67494 [details] Patch Clearing flags on attachment: 67494 Committed r67484: <http://trac.webkit.org/changeset/67484>
All reviewed patches have been landed. Closing bug.
(In reply to comment #6) > Looks like our behavior is correct. Adding tests. Adam, could you explain why the current behavior is correct?
> Adam, could you explain why the current behavior is correct? Sure. </x><!doctype html> This case generates a close tag token for the </x>, which kicks us out of the initial model, so the doctype doesn't trigger standards mode. Hence, quirks. </><!doctype html> or This case doesn't generate any token for </>. It just gets eaten by the tokenizer. That means the first token we see is the doctype, which triggers standards mode. Hence, standards.
(In reply to comment #13) > </><!doctype html> or > > This case doesn't generate any token for </>. It just gets eaten by the tokenizer. That means the first token we see is the doctype, which triggers standards mode. Hence, standards. Is it correct behavior according HTML5 specification [http://www.w3.org/TR/html5/syntax.html#writing]?
> Is it correct behavior according HTML5 specification [http://www.w3.org/TR/html5/syntax.html#writing]? Yes. Notice the first sentence of that section: [[ This section only applies to documents, authoring tools, and markup generators. In particular, it does not apply to conformance checkers; conformance checkers must use the requirements given in the next section ("parsing HTML documents"). ]]