haikuwebkit/LayoutTests/js/dom/document-write-in-load-even...

5 lines
48 B
Plaintext
Raw Permalink Normal View History

ScriptRunner should be driven by PendingScript rather than ScriptElement https://bugs.webkit.org/show_bug.cgi?id=161726 Reviewed by Ryosuke Niwa. Source/WebCore: Tests: js/dom/document-write-in-error-event.html js/dom/document-write-in-load-event.html ScriptRunner is driven by ScriptElement::notifyFinished. While ScriptRunner is driven by this, HTMLScriptRunner does not use it. Instead, HTMLScriptRunner uses PendingScriptClient. As a result, ScriptElement::notifyFinished is used only when the script is annotated with "defer" or "async" while all the external script will load the LoadableScript. It is confusing. This patch removes ScriptElement::notifyFinished and use PendingScript's observability in ScriptRunner instead. This patch also fixes the behavior about ignore-destructive-writes counter[1]. When dispatching the load and error events, this ignore-destructive-writes counter should not be incremeneted by this execution. The added tests ensure this behavior. [1]: https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block * dom/ScriptElement.cpp: Drop LoadableScriptClient interface. (WebCore::ScriptElement::prepareScript): Do not use addClient. ScriptRunner use PendingScript::{setClient,clearClient} instead. (WebCore::ScriptElement::executeScriptForScriptRunner): IgnoreDestructiveWriteCountIncrementer will be done in ScriptElement::executeScript. So no need to do it here, that's duplicated. (WebCore::ScriptElement::~ScriptElement): Deleted. ScriptElement does not use addClient/removeClient. (WebCore::ScriptElement::stopLoadRequest): Deleted. (WebCore::ScriptElement::executeScriptForHTMLScriptRunner): Deleted. executeScriptForHTMLScriptRunner and executeScriptForScriptRunner are merged into executeScriptForRunner. (WebCore::ScriptElement::notifyFinished): Deleted. * dom/ScriptElement.h: (WebCore::ScriptElement::~ScriptElement): (WebCore::ScriptElement::willExecuteInOrder): Used in ScriptRunner to determine whether the script is async or defer. (WebCore::ScriptElement::willExecuteWhenDocumentFinishedParsing): Deleted. * dom/ScriptRunner.cpp: (WebCore::ScriptRunner::~ScriptRunner): HashSet's iterator will return `const PendingScript&`. Another option is using HashSet<RefPtr<PendingScript>>. Here, we use a little bit weired const_cast. (WebCore::ScriptRunner::queueScriptForExecution): Use PendingScript::setClient to wait loading. (WebCore::ScriptRunner::notifyFinished): Notify the script ready here. (WebCore::ScriptRunner::timerFired): Use executeScriptForScriptRunner. (WebCore::ScriptRunner::notifyScriptReady): Deleted. * dom/ScriptRunner.h: * html/parser/HTMLScriptRunner.cpp: (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): Use executeScriptForScriptRunner. LayoutTests: * js/dom/document-write-in-error-event-expected.txt: Added. * js/dom/document-write-in-error-event.html: Added. * js/dom/document-write-in-load-event-expected.txt: Added. * js/dom/document-write-in-load-event.html: Added. * js/dom/script-tests/dummy.js: Added. Canonical link: https://commits.webkit.org/179954@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-09 05:20:17 +00:00
PASS successfullyParsed is true
TEST COMPLETE