OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 } | 152 } |
153 | 153 |
154 void ScriptLoader::DispatchLoadEvent() { | 154 void ScriptLoader::DispatchLoadEvent() { |
155 element_->DispatchLoadEvent(); | 155 element_->DispatchLoadEvent(); |
156 SetHaveFiredLoadEvent(true); | 156 SetHaveFiredLoadEvent(true); |
157 } | 157 } |
158 | 158 |
159 bool ScriptLoader::IsValidScriptTypeAndLanguage( | 159 bool ScriptLoader::IsValidScriptTypeAndLanguage( |
160 const String& type, | 160 const String& type, |
161 const String& language, | 161 const String& language, |
162 bool nomodule, | |
162 LegacyTypeSupport support_legacy_types) { | 163 LegacyTypeSupport support_legacy_types) { |
164 if (RuntimeEnabledFeatures::moduleScriptsEnabled()) { | |
165 if (type == "module") | |
166 return true; | |
167 // https://html.spec.whatwg.org/#prepare-a-script, Step 11. | |
hiroshige
2017/04/15 00:45:09
IsValidScriptTypeAndLanguage() is called as Step 6
Nate Chapin
2017/04/19 20:28:27
Added ScriptLoader::BlockForNoModule()
| |
168 if (nomodule) | |
169 return false; | |
170 } | |
171 | |
163 // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used | 172 // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used |
164 // here to maintain backwards compatibility with existing layout tests. The | 173 // here to maintain backwards compatibility with existing layout tests. The |
165 // specific violations are: | 174 // specific violations are: |
166 // - Allowing type=javascript. type= should only support MIME types, such as | 175 // - Allowing type=javascript. type= should only support MIME types, such as |
167 // text/javascript. | 176 // text/javascript. |
168 // - Allowing a different set of languages for language= and type=. language= | 177 // - Allowing a different set of languages for language= and type=. language= |
169 // supports Javascript 1.1 and 1.4-1.6, but type= does not. | 178 // supports Javascript 1.1 and 1.4-1.6, but type= does not. |
170 if (type.IsEmpty()) { | 179 if (type.IsEmpty()) { |
171 return language.IsEmpty() || // assume text/javascript. | 180 return language.IsEmpty() || // assume text/javascript. |
172 MIMETypeRegistry::IsSupportedJavaScriptMIMEType("text/" + | 181 MIMETypeRegistry::IsSupportedJavaScriptMIMEType("text/" + |
173 language) || | 182 language) || |
174 MIMETypeRegistry::IsLegacySupportedJavaScriptLanguage(language); | 183 MIMETypeRegistry::IsLegacySupportedJavaScriptLanguage(language); |
175 } else if (RuntimeEnabledFeatures::moduleScriptsEnabled() && | |
176 type == "module") { | |
177 return true; | |
178 } else if (MIMETypeRegistry::IsSupportedJavaScriptMIMEType( | 184 } else if (MIMETypeRegistry::IsSupportedJavaScriptMIMEType( |
179 type.StripWhiteSpace()) || | 185 type.StripWhiteSpace()) || |
180 (support_legacy_types == kAllowLegacyTypeInTypeAttribute && | 186 (support_legacy_types == kAllowLegacyTypeInTypeAttribute && |
181 MIMETypeRegistry::IsLegacySupportedJavaScriptLanguage(type))) { | 187 MIMETypeRegistry::IsLegacySupportedJavaScriptLanguage(type))) { |
182 return true; | 188 return true; |
183 } | 189 } |
184 | 190 |
185 return false; | 191 return false; |
186 } | 192 } |
187 | 193 |
188 bool ScriptLoader::IsScriptTypeSupported( | 194 bool ScriptLoader::IsScriptTypeSupported( |
189 LegacyTypeSupport support_legacy_types) const { | 195 LegacyTypeSupport support_legacy_types) const { |
190 return IsValidScriptTypeAndLanguage(element_->TypeAttributeValue(), | 196 return IsValidScriptTypeAndLanguage( |
191 element_->LanguageAttributeValue(), | 197 element_->TypeAttributeValue(), element_->LanguageAttributeValue(), |
192 support_legacy_types); | 198 element_->NomoduleAttributeValue(), support_legacy_types); |
193 } | 199 } |
194 | 200 |
195 // https://html.spec.whatwg.org/#prepare-a-script | 201 // https://html.spec.whatwg.org/#prepare-a-script |
196 bool ScriptLoader::PrepareScript(const TextPosition& script_start_position, | 202 bool ScriptLoader::PrepareScript(const TextPosition& script_start_position, |
197 LegacyTypeSupport support_legacy_types) { | 203 LegacyTypeSupport support_legacy_types) { |
198 // 1. "If the script element is marked as having "already started", then | 204 // 1. "If the script element is marked as having "already started", then |
199 // abort these steps at this point. The script is not executed." | 205 // abort these steps at this point. The script is not executed." |
200 if (already_started_) | 206 if (already_started_) |
201 return false; | 207 return false; |
202 | 208 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 // then abort these steps at this point. The script is not executed. | 787 // then abort these steps at this point. The script is not executed. |
782 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || | 788 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || |
783 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); | 789 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); |
784 } | 790 } |
785 | 791 |
786 String ScriptLoader::ScriptContent() const { | 792 String ScriptLoader::ScriptContent() const { |
787 return element_->TextFromChildren(); | 793 return element_->TextFromChildren(); |
788 } | 794 } |
789 | 795 |
790 } // namespace blink | 796 } // namespace blink |
OLD | NEW |