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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 2877223002: Fix module scripts with for/event attributes (Closed)
Patch Set: Title Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 957
958 // Step 13 of https://html.spec.whatwg.org/#prepare-a-script 958 // Step 13 of https://html.spec.whatwg.org/#prepare-a-script
959 bool ScriptLoader::IsScriptForEventSupported() const { 959 bool ScriptLoader::IsScriptForEventSupported() const {
960 // 1. "Let for be the value of the for attribute." 960 // 1. "Let for be the value of the for attribute."
961 String event_attribute = element_->EventAttributeValue(); 961 String event_attribute = element_->EventAttributeValue();
962 // 2. "Let event be the value of the event attribute." 962 // 2. "Let event be the value of the event attribute."
963 String for_attribute = element_->ForAttributeValue(); 963 String for_attribute = element_->ForAttributeValue();
964 964
965 // "If the script element has an event attribute and a for attribute, and 965 // "If the script element has an event attribute and a for attribute, and
966 // the script's type is "classic", then run these substeps:" 966 // the script's type is "classic", then run these substeps:"
967 // TODO(hiroshige): Check the script's type. 967 if (GetScriptType() != ScriptType::kClassic || event_attribute.IsNull() ||
968 if (event_attribute.IsNull() || for_attribute.IsNull()) 968 for_attribute.IsNull())
969 return true; 969 return true;
970 970
971 // 3. "Strip leading and trailing ASCII whitespace from event and for." 971 // 3. "Strip leading and trailing ASCII whitespace from event and for."
972 for_attribute = for_attribute.StripWhiteSpace(); 972 for_attribute = for_attribute.StripWhiteSpace();
973 // 4. "If for is not an ASCII case-insensitive match for the string 973 // 4. "If for is not an ASCII case-insensitive match for the string
974 // "window", 974 // "window",
975 // then abort these steps at this point. The script is not executed." 975 // then abort these steps at this point. The script is not executed."
976 if (!DeprecatedEqualIgnoringCase(for_attribute, "window")) 976 if (!DeprecatedEqualIgnoringCase(for_attribute, "window"))
977 return false; 977 return false;
978 event_attribute = event_attribute.StripWhiteSpace(); 978 event_attribute = event_attribute.StripWhiteSpace();
979 // 5. "If event is not an ASCII case-insensitive match for either the 979 // 5. "If event is not an ASCII case-insensitive match for either the
980 // string "onload" or the string "onload()", 980 // string "onload" or the string "onload()",
981 // then abort these steps at this point. The script is not executed. 981 // then abort these steps at this point. The script is not executed.
982 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || 982 return DeprecatedEqualIgnoringCase(event_attribute, "onload") ||
983 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); 983 DeprecatedEqualIgnoringCase(event_attribute, "onload()");
984 } 984 }
985 985
986 String ScriptLoader::ScriptContent() const { 986 String ScriptLoader::ScriptContent() const {
987 return element_->TextFromChildren(); 987 return element_->TextFromChildren();
988 } 988 }
989 989
990 } // namespace blink 990 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698