| Index: Source/core/dom/ScriptLoader.cpp
|
| diff --git a/Source/core/dom/ScriptLoader.cpp b/Source/core/dom/ScriptLoader.cpp
|
| index b4d1e0b81b094c1808ed32101a3fcb07b2d9144d..c29e0a261c4aa927abba8120b54cbc487fe170e0 100644
|
| --- a/Source/core/dom/ScriptLoader.cpp
|
| +++ b/Source/core/dom/ScriptLoader.cpp
|
| @@ -24,6 +24,8 @@
|
| #include "config.h"
|
| #include "core/dom/ScriptLoader.h"
|
|
|
| +// FIXMEDART: This should move to bindings/core/dart.
|
| +#include "bindings/core/dart/DartController.h"
|
| #include "bindings/core/v8/ScriptController.h"
|
| #include "bindings/core/v8/ScriptSourceCode.h"
|
| #include "core/HTMLNames.h"
|
| @@ -69,6 +71,7 @@ ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt
|
| , m_willExecuteWhenDocumentFinishedParsing(false)
|
| , m_forceAsync(!parserInserted)
|
| , m_willExecuteInOrder(false)
|
| + , m_scriptType(ScriptJavaScript)
|
| {
|
| ASSERT(m_element);
|
| if (parserInserted && element->document().scriptableDocumentParser() && !element->document().isInDocumentWrite())
|
| @@ -159,7 +162,7 @@ void ScriptLoader::dispatchLoadEvent()
|
| setHaveFiredLoadEvent(true);
|
| }
|
|
|
| -bool ScriptLoader::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
|
| +ScriptLoader::ScriptType ScriptLoader::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
|
| {
|
| // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used here to maintain backwards compatibility with existing layout tests. The specific violations are:
|
| // - Allowing type=javascript. type= should only support MIME types, such as text/javascript.
|
| @@ -168,16 +171,18 @@ bool ScriptLoader::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) c
|
| String type = client()->typeAttributeValue();
|
| String language = client()->languageAttributeValue();
|
| if (type.isEmpty() && language.isEmpty())
|
| - return true; // Assume text/javascript.
|
| + return ScriptJavaScript; // Assume text/javascript.
|
| if (type.isEmpty()) {
|
| type = "text/" + language.lower();
|
| if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySupportedJavaScriptLanguage(language))
|
| - return true;
|
| + return ScriptJavaScript;
|
| } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))) {
|
| - return true;
|
| + return ScriptJavaScript;
|
| + } else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())) {
|
| + return ScriptDart;
|
| }
|
|
|
| - return false;
|
| + return ScriptNone;
|
| }
|
|
|
| // http://dev.w3.org/html5/spec/Overview.html#prepare-a-script
|
| @@ -396,7 +401,13 @@ bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
|
| // Create a script from the script element node, using the script
|
| // block's source and the script block's type.
|
| // Note: This is where the script is compiled and actually executed.
|
| - frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, compilationFinishTime);
|
| + if (m_scriptType == ScriptJavaScript) {
|
| + frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, compilationFinishTime);
|
| + } else if (m_scriptType == ScriptDart) {
|
| + frame->dart().evaluate(sourceCode, this);
|
| + } else {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
|
|
| if (isHTMLScriptLoader(m_element)) {
|
| ASSERT(contextDocument->currentScript() == m_element);
|
|
|