Index: Source/core/dom/ScriptLoader.cpp |
diff --git a/Source/core/dom/ScriptLoader.cpp b/Source/core/dom/ScriptLoader.cpp |
index c29e0a261c4aa927abba8120b54cbc487fe170e0..1023f40c0bc8b587d1d9536364cc7395fb1dbfd4 100644 |
--- a/Source/core/dom/ScriptLoader.cpp |
+++ b/Source/core/dom/ScriptLoader.cpp |
@@ -162,7 +162,34 @@ void ScriptLoader::dispatchLoadEvent() |
setHaveFiredLoadEvent(true); |
} |
-ScriptLoader::ScriptType ScriptLoader::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const |
+bool 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. |
+ // - Allowing a different set of languages for language= and type=. language= supports Javascript 1.1 and 1.4-1.6, but type= does not. |
+ |
+ String type = client()->typeAttributeValue(); |
+ String language = client()->languageAttributeValue(); |
+ if (type.isEmpty() && language.isEmpty()) |
+ return ScriptJavaScript; // Assume text/javascript. |
+ if (type.isEmpty()) { |
+ type = "text/" + language.lower(); |
+ if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySupportedJavaScriptLanguage(language)) |
+ return true; |
+ } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))) { |
+ return true; |
+ } else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())) { |
+ // FIXMEDART: Added check for Dart MIME type |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
+ |
+// FIXMEDART: Added to return ScriptType and to support Dart MIME type similar to isScriptTypeSupported |
+// but returns a enum for the script type. |
+ScriptLoader::ScriptType ScriptLoader::getScriptTypeSupported(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. |
@@ -179,6 +206,7 @@ ScriptLoader::ScriptType ScriptLoader::isScriptTypeSupported(LegacyTypeSupport s |
} else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))) { |
return ScriptJavaScript; |
} else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())) { |
+ // FIXMEDART: Added checked for Dart MIME type |
return ScriptDart; |
} |
@@ -214,6 +242,10 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy |
if (!isScriptTypeSupported(supportLegacyTypes)) |
return false; |
+ // FIXMEDAT: Changed to compute the script type. |
+ m_scriptType = getScriptTypeSupported(supportLegacyTypes); |
+ RELEASE_ASSERT(m_scriptType != ScriptNone); |
+ |
if (wasParserInserted) { |
m_parserInserted = true; |
m_forceAsync = false; |