diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index 015b68f600..900d709f20 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -4610,13 +4610,12 @@ class CalendarMap final { DEFINE_LAZY_LEAKY_OBJECT_GETTER(CalendarMap, GetCalendarMap) -// #sec-temporal-isbuiltincalendar -bool IsBuiltinCalendar(Isolate* isolate, const std::string& id) { - return GetCalendarMap()->Contains(id); -} - bool IsBuiltinCalendar(Isolate* isolate, Handle id) { - return IsBuiltinCalendar(isolate, id->ToCString().get()); + // 1. Let calendars be AvailableCalendars(). + // 2. If calendars contains the ASCII-lowercase of id, return true. + // 3. Return false. + id = Intl::ConvertToLower(isolate, id).ToHandleChecked(); + return GetCalendarMap()->Contains(id->ToCString().get()); } Handle CalendarIdentifier(Isolate* isolate, int32_t index) { @@ -4625,6 +4624,7 @@ Handle CalendarIdentifier(Isolate* isolate, int32_t index) { } int32_t CalendarIndex(Isolate* isolate, Handle id) { + id = Intl::ConvertToLower(isolate, id).ToHandleChecked(); return GetCalendarMap()->Index(id->ToCString().get()); } @@ -4645,9 +4645,24 @@ Handle CalendarIdentifier(Isolate* isolate, int32_t index) { // #sec-temporal-isbuiltincalendar bool IsBuiltinCalendar(Isolate* isolate, Handle id) { - // 1. If id is not "iso8601", return false. - // 2. Return true - return isolate->factory()->iso8601_string()->Equals(*id); + // Note: For build without intl support, the only item in AvailableCalendars() + // is "iso8601". + // 1. Let calendars be AvailableCalendars(). + // 2. If calendars contains the ASCII-lowercase of id, return true. + // 3. Return false. + + // Fast path + if (isolate->factory()->iso8601_string()->Equals(*id)) return true; + if (id->length() != 7) return false; + id = String::Flatten(isolate, id); + + DisallowGarbageCollection no_gc; + const String::FlatContent& flat = id->GetFlatContent(no_gc); + // Return true if id is case insensitive equals to "iso8601". + return AsciiAlphaToLower(flat.Get(0)) == 'i' && + AsciiAlphaToLower(flat.Get(1)) == 's' && + AsciiAlphaToLower(flat.Get(2)) == 'o' && flat.Get(3) == '8' && + flat.Get(4) == '6' && flat.Get(5) == '0' && flat.Get(6) == '1'; } int32_t CalendarIndex(Isolate* isolate, Handle id) { return 0; } diff --git a/test/mjsunit/temporal/calendar-constructor.js b/test/mjsunit/temporal/calendar-constructor.js index d0bf81f56c..12e30236c8 100644 --- a/test/mjsunit/temporal/calendar-constructor.js +++ b/test/mjsunit/temporal/calendar-constructor.js @@ -10,7 +10,6 @@ assertThrows(() => Temporal.Calendar("iso8601"), TypeError); assertThrows(() => new Temporal.Calendar(), RangeError); -// Wrong case -assertThrows(() => new Temporal.Calendar("ISO8601"), RangeError); +assertEquals("iso8601", (new Temporal.Calendar("IsO8601")).id) assertEquals("iso8601", (new Temporal.Calendar("iso8601")).id) diff --git a/test/test262/test262.status b/test/test262/test262.status index a168114673..53d54d48b3 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -427,62 +427,7 @@ 'staging/Intl402/Temporal/old/yearmonth-toLocaleString': [FAIL], 'staging/Intl402/Temporal/old/zoneddatetime-toLocaleString': [FAIL], - 'built-ins/Temporal/Calendar/from/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Now/plainDate/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/Now/zonedDateTime/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainMonthDay/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainYearMonth/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive': [FAIL], - 'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive': [FAIL], # intl402 - 'intl402/Temporal/Calendar/calendar-case-insensitive': [FAIL], - 'intl402/Temporal/Calendar/from/calendar-case-insensitive': [FAIL], - 'intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-case-insensitive': [FAIL], - 'intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-case-insensitive': [FAIL], 'intl402/Temporal/TimeZone/from/timezone-case-insensitive': [FAIL], 'built-ins/Temporal/Duration/compare/precision-exact-mathematical-values-1': [FAIL], @@ -514,7 +459,6 @@ 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-ceil': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-expand': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/roundingmode-floor': [FAIL], - 'intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive': [FAIL], 'built-ins/Temporal/Duration/compare/order-of-operations': [FAIL], 'built-ins/Temporal/Duration/prototype/round/order-of-operations': [FAIL],