(From discussion on https://chromium-review.googlesource.com/c/chromium/src/+/1224791)
In DOMParser.parseFromString when StopParsing has been called (which it will be for instance when we encounter a "broken" attribute), end() will not be called. The reason for this is that it uses Document::SetContent which does open(), <append data>, close() - and close() will return early if the parser is not in the "parsing" state.
Maybe SetContent should use lower level primitives to achieve what it sets out to do, or maybe DOMParser.parseFromString should mimic cases like for instance innerHTML (which is very similar modulo the DocumentFragment.)
One might also argue that Document::close shouldn't be checking the parsing state where it is, and rather just check the "was create by script" flag - which is closer to the speced behavior. This seems like a more general thing though.
Relevant spec starting point:
https://w3c.github.io/DOM-Parsing/#dfn-parsefromstring
Comment 1 by bugdroid1@chromium.org
, Oct 25