[WebCore] Clean up script loading code in XML
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2016 06:47:31 +0000 (06:47 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2016 06:47:31 +0000 (06:47 +0000)
commitfc0071d2a46eeec846193c926feb75fe1f32501c
treeadb986046b95fa9a0aec619627401a33ec713f83
parentb8a991e82428b7264bb912c20402af9d5d19b768
[WebCore] Clean up script loading code in XML
https://bugs.webkit.org/show_bug.cgi?id=161651

Reviewed by Ryosuke Niwa.

Source/WebCore:

This patch cleans up XML document script handling by using PendingScript.
Previously, we directly used CachedScript. But it is not good since we
have PendingScript wrapper.

We also disable ES6 modules for non HTML document. While ES6 modules tag
requires "defer" semantics, "defer" semantics is not implemented in non
HTML documents. And ES6 module tag is only specified in whatwg HTML spec.

* dom/LoadableClassicScript.cpp:
(WebCore::LoadableClassicScript::execute):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::determineScriptType):
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::executeClassicScript):
(WebCore::ScriptElement::executePendingScript):
(WebCore::ScriptElement::executeScript): Deleted.
(WebCore::ScriptElement::executeScriptForScriptRunner): Deleted.
* dom/ScriptElement.h:
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::timerFired):
* html/parser/HTMLDocumentParser.cpp:
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
(WebCore::HTMLScriptRunner::runScript):
* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::notifyFinished):
* xml/parser/XMLDocumentParser.h:
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::~XMLDocumentParser):
(WebCore::XMLDocumentParser::endElementNs):

LayoutTests:

Add tests that ensure modules are not executed in XHTML documents.

* js/dom/modules/module-inline-dynamic-in-xhtml-expected.txt: Added.
* js/dom/modules/module-inline-dynamic-in-xhtml.xhtml: Added.
* js/dom/modules/module-inline-simple-in-xhtml-expected.txt: Added.
* js/dom/modules/module-inline-simple-in-xhtml.xhtml: Added.
* js/dom/modules/module-src-dynamic-in-xhtml-expected.txt: Added.
* js/dom/modules/module-src-dynamic-in-xhtml.xhtml: Added.
* js/dom/modules/module-src-simple-in-xhtml-expected.txt: Added.
* js/dom/modules/module-src-simple-in-xhtml.xhtml: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/modules/module-inline-dynamic-in-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/modules/module-inline-dynamic-in-xhtml.xhtml [new file with mode: 0644]
LayoutTests/js/dom/modules/module-inline-simple-in-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/modules/module-inline-simple-in-xhtml.xhtml [new file with mode: 0644]
LayoutTests/js/dom/modules/module-src-dynamic-in-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/modules/module-src-dynamic-in-xhtml.xhtml [new file with mode: 0644]
LayoutTests/js/dom/modules/module-src-simple-in-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/modules/module-src-simple-in-xhtml.xhtml [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/LoadableClassicScript.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/dom/ScriptElement.h
Source/WebCore/dom/ScriptRunner.cpp
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/html/parser/HTMLScriptRunner.cpp
Source/WebCore/xml/parser/XMLDocumentParser.cpp
Source/WebCore/xml/parser/XMLDocumentParser.h
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp