Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: Source/core/dom/ScriptLoader.cpp

Issue 1659793004: Fixed handling of Dart MIME type (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/2454_1
Patch Set: Updated comment Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698