Commit ad4bd885 authored by Timothy Gu's avatar Timothy Gu Committed by Commit Bot

Align executing script bailout in document.open with spec

HTMLDocumentParser::IsExecutingScript() is in fact identical to the
"script nesting level is greater than 0" check in the current HTML
Standard.

The removed check originated from an older version of the HTML Standard
that read:

> If the Document has an active parser that isn't a script-created
> parser, and the insertion point associated with that parser's input
> stream is not undefined (that is, it does point to somewhere in the
> input stream), then the method does nothing.

but that was changed after [1]/[2] to the current text which covers
strictly more cases. Indeed, in the current coverage report the removed
check is never true [3].

The check is expected to stay in its current form in the upcoming
document.open() overhaul.

[1]: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17869
[2]: https://github.com/whatwg/html/commit/7b0112bbfb4923e8f64b0fd1c66d14fbd526fc33
[3]: https://chromium-coverage.appspot.com/reports/577000/linux/chromium/src/third_party/blink/renderer/core/dom/document.cc.html#L3048

Bug: 866274
Change-Id: I5f4547ee62efe45a9831c003854279b3490a08f1
Reviewed-on: https://chromium-review.googlesource.com/1146202Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Timothy Gu <timothygu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579290}
parent b2a6d759
......@@ -3043,15 +3043,12 @@ void Document::open() {
DCHECK(!ImportLoader());
if (frame_) {
// https://html.spec.whatwg.org/C/dynamic-markup-insertion.html#document-open-steps
// If |document| has an active parser whose script nesting level is greater
// than 0, then return |document|.
if (ScriptableDocumentParser* parser = GetScriptableDocumentParser()) {
if (parser->IsParsing()) {
// FIXME: HTML5 doesn't tell us to check this, it might not be correct.
if (parser->IsExecutingScript())
return;
if (!parser->WasCreatedByScript() && parser->HasInsertionPoint())
return;
}
if (parser->IsParsing() && parser->IsExecutingScript())
return;
}
if (frame_->Loader().HasProvisionalNavigation()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment