haikuwebkit/LayoutTests/js/unicode-escape-sequences.html

9 lines
216 B
HTML
Raw Permalink Normal View History

[ES6] Implement Unicode code point escapes https://bugs.webkit.org/show_bug.cgi?id=144377 Reviewed by Antti Koivisto. Source/JavaScriptCore: * parser/Lexer.cpp: Moved the UnicodeHexValue class in here from the header. Made it a non-member class so it doesn't need to be part of a template. Made it use UChar32 instead of int for the value to make it clearer what goes into this class. (JSC::ParsedUnicodeEscapeValue::isIncomplete): Added. Replaces the old type() function. (JSC::Lexer<CharacterType>::parseUnicodeEscape): Renamed from parseFourDigitUnicodeHex and added support for code point escapes. (JSC::isLatin1): Added an overload for UChar32. (JSC::isIdentStart): Changed this to take UChar32; no caller tries to call it with a UChar, so no need to overload for that type for now. (JSC::isNonLatin1IdentPart): Changed argument type to UChar32 for clarity. Also added FIXME about a subtle ES6 change that we might want to make later. (JSC::isIdentPart): Changed this to take UChar32; no caller tries to call it with a UChar, so no need to overload for that type for now. (JSC::isIdentPartIncludingEscapeTemplate): Made this a template so that we don't need to repeat the code twice. Added code to handle code point escapes. (JSC::isIdentPartIncludingEscape): Call the template instead of having the code in line. (JSC::Lexer<CharacterType>::recordUnicodeCodePoint): Added. (JSC::Lexer<CharacterType>::parseIdentifierSlowCase): Made small tweaks and updated to call parseUnicodeEscape instead of parseFourDigitUnicodeHex. (JSC::Lexer<CharacterType>::parseComplexEscape): Call parseUnicodeEscape instead of parseFourDigitUnicodeHex. Move the code to handle "\u" before the code that handles the escapes, since the code point escape code now consumes characters while parsing rather than peeking ahead. Test case covers this: Symptom would be that "\u{" would evaluate to "u" instead of giving a syntax error. * parser/Lexer.h: Updated for above changes. * runtime/StringConstructor.cpp: (JSC::stringFromCodePoint): Use ICU's UCHAR_MAX_VALUE instead of writing out 0x10FFFF; clearer this way. Source/WebCore: Test: js/unicode-escape-sequences.html * css/CSSParser.cpp: (WebCore::CSSParser::parseEscape): Use ICU's UCHAR_MAX_VALUE instead of writing out 0x10FFFF; clearer this way. Also use our replacementCharacter instead of writing out 0xFFFD. * html/parser/HTMLEntityParser.cpp: (WebCore::isAlphaNumeric): Deleted. (WebCore::HTMLEntityParser::legalEntityFor): Use ICU's UCHAR_MAX_VALUE and U_IS_SURROGATE instead of writing the code out. Didn't use U_IS_UNICODE_CHAR because that also includes U_IS_UNICODE_NONCHAR and thus would change behavior, but maye it's something we want to do in the future. (WebCore::HTMLEntityParser::consumeNamedEntity): Use isASCIIAlphanumeric instead of a the function in this file that does the same thing less efficiently. * html/parser/InputStreamPreprocessor.h: (WebCore::InputStreamPreprocessor::processNextInputCharacter): Use replacementCharacter from CharacterNames.h instead of writing out 0xFFFd. * xml/parser/CharacterReferenceParserInlines.h: (WebCore::consumeCharacterReference): Use ICU's UCHAR_MAX_VALUE instead of defining our own local highestValidCharacter constant. LayoutTests: * js/script-tests/unicode-escape-sequences.js: Added. * js/unicode-escape-sequences-expected.txt: Added. * js/unicode-escape-sequences.html: Added. Generated with make-script-test-wrappers. Canonical link: https://commits.webkit.org/162396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-29 16:33:12 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../resources/js-test-pre.js"></script>
<script src="script-tests/unicode-escape-sequences.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>