diff --git a/include/v8-isolate.h b/include/v8-isolate.h index 0f87f61d1ffa..661dde91ef56 100644 --- a/include/v8-isolate.h +++ b/include/v8-isolate.h @@ -537,6 +537,8 @@ class V8_EXPORT Isolate { kInvalidatedNumberStringPrototypeNoReplaceProtector = 118, kRegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119, // Unused. kImportAssertionDeprecatedSyntax = 120, + kLocaleInfoObsoletedGetters = 121, + kLocaleInfoFunctions = 122, // If you add new values here, you'll also need to update Chromium's: // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to diff --git a/src/builtins/builtins-definitions.h b/src/builtins/builtins-definitions.h index a355ca52382f..f1836e52f4ac 100644 --- a/src/builtins/builtins-definitions.h +++ b/src/builtins/builtins-definitions.h @@ -1796,6 +1796,20 @@ namespace internal { CPP(LocalePrototypeCollation) \ /* ecma402 #sec-Intl.Locale.prototype.collations */ \ CPP(LocalePrototypeCollations) \ + /* ecma402 #sec-Intl.Locale.prototype.getCalendars */ \ + CPP(LocalePrototypeGetCalendars) \ + /* ecma402 #sec-Intl.Locale.prototype.getCollations */ \ + CPP(LocalePrototypeGetCollations) \ + /* ecma402 #sec-Intl.Locale.prototype.getHourCycles */ \ + CPP(LocalePrototypeGetHourCycles) \ + /* ecma402 #sec-Intl.Locale.prototype.getNumberingSystems */ \ + CPP(LocalePrototypeGetNumberingSystems) \ + /* ecma402 #sec-Intl.Locale.prototype.getTimeZones */ \ + CPP(LocalePrototypeGetTimeZones) \ + /* ecma402 #sec-Intl.Locale.prototype.getTextInfo */ \ + CPP(LocalePrototypeGetTextInfo) \ + /* ecma402 #sec-Intl.Locale.prototype.getWeekInfo */ \ + CPP(LocalePrototypeGetWeekInfo) \ /* ecma402 #sec-Intl.Locale.prototype.hourCycle */ \ CPP(LocalePrototypeHourCycle) \ /* ecma402 #sec-Intl.Locale.prototype.hourCycles */ \ diff --git a/src/builtins/builtins-intl.cc b/src/builtins/builtins-intl.cc index a6815a4afe4c..992f19cb3ae5 100644 --- a/src/builtins/builtins-intl.cc +++ b/src/builtins/builtins-intl.cc @@ -721,47 +721,111 @@ BUILTIN(LocalePrototypeMinimize) { RETURN_RESULT_OR_FAILURE(isolate, JSLocale::Minimize(isolate, locale)); } +BUILTIN(LocalePrototypeGetCalendars) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getCalendars"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetCalendars(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetCollations) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getCollations"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetCollations(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetHourCycles) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getHourCycles"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetHourCycles(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetNumberingSystems) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getNumberingSystems"); + RETURN_RESULT_OR_FAILURE(isolate, + JSLocale::GetNumberingSystems(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetTextInfo) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getTextInfo"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetTextInfo(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetTimeZones) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getTimeZones"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetTimeZones(isolate, locale)); +} + +BUILTIN(LocalePrototypeGetWeekInfo) { + HandleScope scope(isolate); + isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocaleInfoFunctions); + CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.getWeekInfo"); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetWeekInfo(isolate, locale)); +} + BUILTIN(LocalePrototypeCalendars) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.calendars"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::Calendars(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetCalendars(isolate, locale)); } BUILTIN(LocalePrototypeCollations) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.collations"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::Collations(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetCollations(isolate, locale)); } BUILTIN(LocalePrototypeHourCycles) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.hourCycles"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::HourCycles(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetHourCycles(isolate, locale)); } BUILTIN(LocalePrototypeNumberingSystems) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.numberingSystems"); RETURN_RESULT_OR_FAILURE(isolate, - JSLocale::NumberingSystems(isolate, locale)); + JSLocale::GetNumberingSystems(isolate, locale)); } BUILTIN(LocalePrototypeTextInfo) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.textInfo"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::TextInfo(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetTextInfo(isolate, locale)); } BUILTIN(LocalePrototypeTimeZones) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.timeZones"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::TimeZones(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetTimeZones(isolate, locale)); } BUILTIN(LocalePrototypeWeekInfo) { HandleScope scope(isolate); + isolate->CountUsage( + v8::Isolate::UseCounterFeature::kLocaleInfoObsoletedGetters); CHECK_RECEIVER(JSLocale, locale, "Intl.Locale.prototype.weekInfo"); - RETURN_RESULT_OR_FAILURE(isolate, JSLocale::WeekInfo(isolate, locale)); + RETURN_RESULT_OR_FAILURE(isolate, JSLocale::GetWeekInfo(isolate, locale)); } BUILTIN(RelativeTimeFormatSupportedLocalesOf) { diff --git a/src/debug/debug-evaluate.cc b/src/debug/debug-evaluate.cc index 48349f193dce..5b8330b8fdca 100644 --- a/src/debug/debug-evaluate.cc +++ b/src/debug/debug-evaluate.cc @@ -916,6 +916,13 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtin id) { case Builtin::kLocalePrototypeCaseFirst: case Builtin::kLocalePrototypeCollation: case Builtin::kLocalePrototypeCollations: + case Builtin::kLocalePrototypeGetCalendars: + case Builtin::kLocalePrototypeGetCollations: + case Builtin::kLocalePrototypeGetHourCycles: + case Builtin::kLocalePrototypeGetNumberingSystems: + case Builtin::kLocalePrototypeGetTextInfo: + case Builtin::kLocalePrototypeGetTimeZones: + case Builtin::kLocalePrototypeGetWeekInfo: case Builtin::kLocalePrototypeHourCycle: case Builtin::kLocalePrototypeHourCycles: case Builtin::kLocalePrototypeLanguage: diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h index 81eff57273ec..dc1a26707908 100644 --- a/src/flags/flag-definitions.h +++ b/src/flags/flag-definitions.h @@ -244,9 +244,14 @@ DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features") V(harmony_iterator_helpers, "JavaScript iterator helpers") #ifdef V8_INTL_SUPPORT -#define HARMONY_INPROGRESS(V) \ - HARMONY_INPROGRESS_BASE(V) \ - V(harmony_intl_best_fit_matcher, "Intl BestFitMatcher") \ +#define HARMONY_INPROGRESS(V) \ + HARMONY_INPROGRESS_BASE(V) \ + V(harmony_intl_best_fit_matcher, "Intl BestFitMatcher") \ + /* Following two flags should ship the same time but may stage */ \ + /* differently . */ \ + V(harmony_remove_intl_locale_info_getters, \ + "Remove Obsoleted Intl Locale Info getters") \ + V(harmony_intl_locale_info_func, "Intl Locale Info API as functions") \ V(harmony_intl_duration_format, "Intl DurationFormat API") #else #define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V) diff --git a/src/init/bootstrapper.cc b/src/init/bootstrapper.cc index e52be9678a35..1ca6b270f3cf 100644 --- a/src/init/bootstrapper.cc +++ b/src/init/bootstrapper.cc @@ -3155,22 +3155,24 @@ void Genesis::InitializeGlobal(Handle global_object, factory->numberingSystem_string(), Builtin::kLocalePrototypeNumberingSystem, true); - // Intl Locale Info functions - SimpleInstallGetter(isolate(), prototype, factory->calendars_string(), - Builtin::kLocalePrototypeCalendars, true); - SimpleInstallGetter(isolate(), prototype, factory->collations_string(), - Builtin::kLocalePrototypeCollations, true); - SimpleInstallGetter(isolate(), prototype, factory->hourCycles_string(), - Builtin::kLocalePrototypeHourCycles, true); - SimpleInstallGetter(isolate(), prototype, - factory->numberingSystems_string(), - Builtin::kLocalePrototypeNumberingSystems, true); - SimpleInstallGetter(isolate(), prototype, factory->textInfo_string(), - Builtin::kLocalePrototypeTextInfo, true); - SimpleInstallGetter(isolate(), prototype, factory->timeZones_string(), - Builtin::kLocalePrototypeTimeZones, true); - SimpleInstallGetter(isolate(), prototype, factory->weekInfo_string(), - Builtin::kLocalePrototypeWeekInfo, true); + if (!v8_flags.harmony_remove_intl_locale_info_getters) { + // Intl Locale Info functions + SimpleInstallGetter(isolate(), prototype, factory->calendars_string(), + Builtin::kLocalePrototypeCalendars, true); + SimpleInstallGetter(isolate(), prototype, factory->collations_string(), + Builtin::kLocalePrototypeCollations, true); + SimpleInstallGetter(isolate(), prototype, factory->hourCycles_string(), + Builtin::kLocalePrototypeHourCycles, true); + SimpleInstallGetter(isolate(), prototype, + factory->numberingSystems_string(), + Builtin::kLocalePrototypeNumberingSystems, true); + SimpleInstallGetter(isolate(), prototype, factory->textInfo_string(), + Builtin::kLocalePrototypeTextInfo, true); + SimpleInstallGetter(isolate(), prototype, factory->timeZones_string(), + Builtin::kLocalePrototypeTimeZones, true); + SimpleInstallGetter(isolate(), prototype, factory->weekInfo_string(), + Builtin::kLocalePrototypeWeekInfo, true); + } } { // -- D i s p l a y N a m e s @@ -4533,6 +4535,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rab_gsab_transfer) #ifdef V8_INTL_SUPPORT EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_best_fit_matcher) +EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_remove_intl_locale_info_getters) #endif // V8_INTL_SUPPORT #undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE @@ -5671,6 +5674,27 @@ void Genesis::InitializeGlobal_harmony_intl_number_format_v3() { #endif // V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT +void Genesis::InitializeGlobal_harmony_intl_locale_info_func() { + if (!v8_flags.harmony_intl_locale_info_func) return; + Handle prototype( + JSObject::cast(native_context()->intl_locale_function().prototype()), + isolate_); + SimpleInstallFunction(isolate(), prototype, "getCalendars", + Builtin::kLocalePrototypeGetCalendars, 0, false); + SimpleInstallFunction(isolate(), prototype, "getCollations", + Builtin::kLocalePrototypeGetCollations, 0, false); + SimpleInstallFunction(isolate(), prototype, "getHourCycles", + Builtin::kLocalePrototypeGetHourCycles, 0, false); + SimpleInstallFunction(isolate(), prototype, "getNumberingSystems", + Builtin::kLocalePrototypeGetNumberingSystems, 0, false); + SimpleInstallFunction(isolate(), prototype, "getTimeZones", + Builtin::kLocalePrototypeGetTimeZones, 0, false); + SimpleInstallFunction(isolate(), prototype, "getTextInfo", + Builtin::kLocalePrototypeGetTextInfo, 0, false); + SimpleInstallFunction(isolate(), prototype, "getWeekInfo", + Builtin::kLocalePrototypeGetWeekInfo, 0, false); +} + void Genesis::InitializeGlobal_harmony_intl_duration_format() { if (!v8_flags.harmony_intl_duration_format) return; Handle intl = Handle::cast( diff --git a/src/objects/js-locale.cc b/src/objects/js-locale.cc index 11eef76f4983..6b48206185d8 100644 --- a/src/objects/js-locale.cc +++ b/src/objects/js-locale.cc @@ -515,8 +515,8 @@ MaybeHandle CalendarsForLocale(Isolate* isolate, } // namespace -MaybeHandle JSLocale::Calendars(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetCalendars(Isolate* isolate, + Handle locale) { icu::Locale icu_locale(*(locale->icu_locale().raw())); return CalendarsForLocale(isolate, icu_locale, true, false); } @@ -526,16 +526,16 @@ MaybeHandle Intl::AvailableCalendars(Isolate* isolate) { return CalendarsForLocale(isolate, icu_locale, false, true); } -MaybeHandle JSLocale::Collations(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetCollations(Isolate* isolate, + Handle locale) { icu::Locale icu_locale(*(locale->icu_locale().raw())); return GetKeywordValuesFromLocale( isolate, "collations", "co", icu_locale, Intl::RemoveCollation, true, true); } -MaybeHandle JSLocale::HourCycles(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetHourCycles(Isolate* isolate, + Handle locale) { // Let preferred be loc.[[HourCycle]]. // Let locale be loc.[[Locale]]. icu::Locale icu_locale(*(locale->icu_locale().raw())); @@ -593,8 +593,8 @@ MaybeHandle JSLocale::HourCycles(Isolate* isolate, return factory->NewJSArrayWithElements(fixed_array); } -MaybeHandle JSLocale::NumberingSystems(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetNumberingSystems(Isolate* isolate, + Handle locale) { // Let preferred be loc.[[NumberingSystem]]. // Let locale be loc.[[Locale]]. @@ -623,8 +623,8 @@ MaybeHandle JSLocale::NumberingSystems(Isolate* isolate, return factory->NewJSArrayWithElements(fixed_array); } -MaybeHandle JSLocale::TimeZones(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetTimeZones(Isolate* isolate, + Handle locale) { // Let loc be the this value. // Perform ? RequireInternalSlot(loc, [[InitializedLocale]]) @@ -663,8 +663,8 @@ MaybeHandle JSLocale::TimeZones(Isolate* isolate, return Intl::ToJSArray(isolate, nullptr, enumeration.get(), nullptr, true); } -MaybeHandle JSLocale::TextInfo(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetTextInfo(Isolate* isolate, + Handle locale) { // Let loc be the this value. // Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). @@ -703,8 +703,8 @@ MaybeHandle JSLocale::TextInfo(Isolate* isolate, return info; } -MaybeHandle JSLocale::WeekInfo(Isolate* isolate, - Handle locale) { +MaybeHandle JSLocale::GetWeekInfo(Isolate* isolate, + Handle locale) { // Let loc be the this value. // Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). diff --git a/src/objects/js-locale.h b/src/objects/js-locale.h index 5f57dca51693..7be93dba8b3d 100644 --- a/src/objects/js-locale.h +++ b/src/objects/js-locale.h @@ -40,19 +40,19 @@ class JSLocale : public TorqueGeneratedJSLocale { static MaybeHandle Minimize(Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle Calendars( + V8_WARN_UNUSED_RESULT static MaybeHandle GetCalendars( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle Collations( + V8_WARN_UNUSED_RESULT static MaybeHandle GetCollations( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle HourCycles( + V8_WARN_UNUSED_RESULT static MaybeHandle GetHourCycles( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle NumberingSystems( + V8_WARN_UNUSED_RESULT static MaybeHandle GetNumberingSystems( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle TextInfo( + V8_WARN_UNUSED_RESULT static MaybeHandle GetTextInfo( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle TimeZones( + V8_WARN_UNUSED_RESULT static MaybeHandle GetTimeZones( Isolate* isolate, Handle locale); - V8_WARN_UNUSED_RESULT static MaybeHandle WeekInfo( + V8_WARN_UNUSED_RESULT static MaybeHandle GetWeekInfo( Isolate* isolate, Handle locale); static Handle Language(Isolate* isolate, Handle locale); diff --git a/test/intl/locale/locale-calendars.js b/test/intl/locale/locale-getCalendars.js similarity index 72% rename from test/intl/locale/locale-calendars.js rename to test/intl/locale/locale-getCalendars.js index e3dde03b20a9..508f62aeb060 100644 --- a/test/intl/locale/locale-calendars.js +++ b/test/intl/locale/locale-getCalendars.js @@ -1,17 +1,18 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func -// Test the return items of calendars fit 'type' +// Test the return items of getCalendars() fit 'type' let a_to_z = "abcdefghijklmnopqrstuvwxyz"; let regex = /^[a-zA-Z0-9]{3,8}(-[a-zA-Z0-9]{3,8})*$/; for (var i = 0; i < a_to_z.length; i++) { for (var j = 0; j < a_to_z.length; j++) { let l = a_to_z[i] + a_to_z[j]; let locale = new Intl.Locale(l); - locale.calendars.forEach(function(tokens) { + locale.getCalendars().forEach(function(tokens) { assertTrue(regex.test(tokens), - locale + ".calendars [" + locale.calendars + + locale + ".getCalendars [" + locale.getCalendars() + "] but '" + tokens + "' does not meet 'type: alphanum{3,8}(sep alphanum{3,8})*'"); }); } diff --git a/test/intl/locale/locale-collations.js b/test/intl/locale/locale-getCollations.js similarity index 66% rename from test/intl/locale/locale-collations.js rename to test/intl/locale/locale-getCollations.js index 96c19989306a..479a2b40b387 100644 --- a/test/intl/locale/locale-collations.js +++ b/test/intl/locale/locale-getCollations.js @@ -1,8 +1,9 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func -// Test the return items of collations fit 'type' +// Test the return items of getCollations() fit 'type' let a_to_z = "abcdefghijklmnopqrstuvwxyz"; let regex = /^[a-zA-Z0-9]{3,8}(-[a-zA-Z0-9]{3,8})*$/; for (var i = 0; i < a_to_z.length; i++) { @@ -10,11 +11,11 @@ for (var i = 0; i < a_to_z.length; i++) { let l = a_to_z[i] + a_to_z[j]; let locale = new Intl.Locale(l); print(locale); - locale.collations.forEach(function(tokens) { + locale.getCollations().forEach(function(tokens) { assertTrue(regex.test(tokens), - locale + ".collations [" + locale.collations + + locale + ".collations [" + locale.getCollations() + "] does not meet 'type: alphanum{3,8}(sep alphanum{3,8})*'"); }); - assertArrayEquals(locale.collations, locale.collations.sort()); + assertArrayEquals(locale.getCollations(), locale.getCollations().sort()); } } diff --git a/test/intl/locale/locale-info-check-property.js b/test/intl/locale/locale-info-check-property.js index 76d219b3610a..b95217af323a 100644 --- a/test/intl/locale/locale-info-check-property.js +++ b/test/intl/locale/locale-info-check-property.js @@ -1,21 +1,20 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Check getter properties against the spec. +// Flags: --harmony-intl-locale-info-func +// Check function properties against the spec. function checkProperties(property) { let desc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, property); - assertEquals(`get ${property}`, desc.get.name); - assertEquals('function', typeof desc.get) - assertEquals(undefined, desc.set); + assertEquals('function', typeof desc.value) assertFalse(desc.enumerable); assertTrue(desc.configurable); + assertTrue(desc.writable); } -checkProperties('calendars'); -checkProperties('collations'); -checkProperties('hourCycles'); -checkProperties('numberingSystems'); -checkProperties('textInfo'); -checkProperties('timeZones'); -checkProperties('weekInfo'); +checkProperties('getCalendars'); +checkProperties('getCollations'); +checkProperties('getHourCycles'); +checkProperties('getNumberingSystems'); +checkProperties('getTextInfo'); +checkProperties('getTimeZones'); +checkProperties('getWeekInfo'); diff --git a/test/intl/locale/locale-info-check-return-types.js b/test/intl/locale/locale-info-check-return-types.js index a2b9033c131c..e0e4ab167c5f 100644 --- a/test/intl/locale/locale-info-check-return-types.js +++ b/test/intl/locale/locale-info-check-return-types.js @@ -1,33 +1,34 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func function checkLocale(locale) { let l = new Intl.Locale(locale); - assertTrue(Array.isArray(l.calendars)); - assertTrue(Array.isArray(l.collations)); - assertTrue(Array.isArray(l.hourCycles)); - assertTrue(Array.isArray(l.numberingSystems)); + assertTrue(Array.isArray(l.getCalendars())); + assertTrue(Array.isArray(l.getCollations())); + assertTrue(Array.isArray(l.getHourCycles())); + assertTrue(Array.isArray(l.getNumberingSystems())); if (l.region == undefined) { - assertEquals(undefined, l.timeZones); + assertEquals(undefined, l.getTimeZones()); } else { - assertTrue(Array.isArray(l.timeZones)); + assertTrue(Array.isArray(l.getTimeZones())); } - assertEquals("object", typeof(l.textInfo)); - assertEquals(1, Object.keys(l.textInfo).length); - assertEquals("string", typeof(l.textInfo.direction)); + assertEquals("object", typeof(l.getTextInfo())); + assertEquals(1, Object.keys(l.getTextInfo()).length); + assertEquals("string", typeof(l.getTextInfo().direction)); - assertEquals("object", typeof(l.weekInfo)); - assertEquals(3, Object.keys(l.weekInfo).length); - assertEquals("number", typeof(l.weekInfo.firstDay)); - assertTrue(l.weekInfo.firstDay >= 1); - assertTrue(l.weekInfo.firstDay <= 7); + assertEquals("object", typeof(l.getWeekInfo())); + assertEquals(3, Object.keys(l.getWeekInfo()).length); + assertEquals("number", typeof(l.getWeekInfo().firstDay)); + assertTrue(l.getWeekInfo().firstDay >= 1); + assertTrue(l.getWeekInfo().firstDay <= 7); - assertEquals("object", typeof(l.weekInfo.weekend)); + assertEquals("object", typeof(l.getWeekInfo().weekend)); let last = 0; - l.weekInfo.weekend.forEach((we) => { + l.getWeekInfo().weekend.forEach((we) => { // In right range assertTrue(we >= 1); assertTrue(we <= 7); @@ -36,9 +37,9 @@ function checkLocale(locale) { last = we; }); - assertEquals("number", typeof(l.weekInfo.minimalDays)); - assertTrue(l.weekInfo.minimalDays >= 1); - assertTrue(l.weekInfo.minimalDays <= 7); + assertEquals("number", typeof(l.getWeekInfo().minimalDays)); + assertTrue(l.getWeekInfo().minimalDays >= 1); + assertTrue(l.getWeekInfo().minimalDays <= 7); } checkLocale("ar"); diff --git a/test/intl/locale/locale-info-ext.js b/test/intl/locale/locale-info-ext.js index c0ca81a3be53..3858d12a4583 100644 --- a/test/intl/locale/locale-info-ext.js +++ b/test/intl/locale/locale-info-ext.js @@ -1,24 +1,25 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func // Test Unicode extension. function testExt(base, ukey, uvalue, property) { let baseLocale = new Intl.Locale(base); let extLocale = new Intl.Locale(base + "-u-" + ukey + "-" + uvalue); - let baseActual = baseLocale[property]; + let baseActual = baseLocale[property](); assertTrue(Array.isArray(baseActual)); assertTrue(baseActual.length > 0); assertFalse(uvalue == baseActual[0]); - let extActual = extLocale[property]; + let extActual = extLocale[property](); assertTrue(Array.isArray(extActual)); assertEquals(1, extActual.length); assertEquals(uvalue, extActual[0]); } -testExt("ar", "ca", "roc", "calendars"); -testExt("fr", "nu", "thai", "numberingSystems"); -testExt("th", "co", "pinyin", "collations"); -testExt("ko", "hc", "h11", "hourCycles"); +testExt("ar", "ca", "roc", "getCalendars"); +testExt("fr", "nu", "thai", "getNumberingSystems"); +testExt("th", "co", "pinyin", "getCollations"); +testExt("ko", "hc", "h11", "getHourCycles"); diff --git a/test/intl/locale/locale-info-no-undefined.js b/test/intl/locale/locale-info-no-undefined.js index 1284be7f2093..9e0e119f209c 100644 --- a/test/intl/locale/locale-info-no-undefined.js +++ b/test/intl/locale/locale-info-no-undefined.js @@ -1,6 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func // Check the return array has no undefined function checkNoUndefined(l, items) { @@ -10,12 +11,12 @@ function checkNoUndefined(l, items) { } function checkLocale(locale) { let l = new Intl.Locale(locale) - checkNoUndefined(l, l.calendars); - checkNoUndefined(l, l.collations); - checkNoUndefined(l, l.hourCycles); - checkNoUndefined(l, l.numberingSystems); + checkNoUndefined(l, l.getCalendars()); + checkNoUndefined(l, l.getCollations()); + checkNoUndefined(l, l.getHourCycles()); + checkNoUndefined(l, l.getNumberingSystems()); if (l.region != undefined) { - checkNoUndefined(l, l.timeZones); + checkNoUndefined(l, l.getTimeZones()); } } diff --git a/test/intl/locale/locale-info-timezones-sorted.js b/test/intl/locale/locale-info-timezones-sorted.js index 60f1ffe81863..fafbfa78e7b8 100644 --- a/test/intl/locale/locale-info-timezones-sorted.js +++ b/test/intl/locale/locale-info-timezones-sorted.js @@ -1,6 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func // Check the return array are sorted function checkSortedArray(l, name, items) { @@ -9,7 +10,7 @@ function checkSortedArray(l, name, items) { } function checkLocale(locale) { let l = new Intl.Locale(locale) - checkSortedArray(l, "timeZones", l.timeZones); + checkSortedArray(l, "getTimeZones", l.getTimeZones()); } checkLocale("ar-EG"); diff --git a/test/intl/locale/locale-numberingSystems.js b/test/intl/locale/locale-numberingSystems.js index 82941647e157..9ff6b185924f 100644 --- a/test/intl/locale/locale-numberingSystems.js +++ b/test/intl/locale/locale-numberingSystems.js @@ -1,6 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-locale-info-func // Test the return items of numberingSystems fit 'type' let a_to_z = "abcdefghijklmnopqrstuvwxyz"; @@ -9,9 +10,9 @@ for (var i = 0; i < a_to_z.length; i++) { for (var j = 0; j < a_to_z.length; j++) { let l = a_to_z[i] + a_to_z[j]; let locale = new Intl.Locale(l); - locale.numberingSystems.forEach(function(tokens) { + locale.getNumberingSystems().forEach(function(tokens) { assertTrue(regex.test(tokens), - locale + ".numberingSystems [" + locale.numberingSystems + + locale + ".numberingSystems [" + locale.getNumberingSystems() + "] does not meet 'type: alphanum{3,8}(sep alphanum{3,8})*'"); }); } diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py index 12bf76b136a7..16c82a308cdd 100644 --- a/test/test262/testcfg.py +++ b/test/test262/testcfg.py @@ -43,6 +43,7 @@ FEATURE_FLAGS = { 'Intl.NumberFormat-v3': '--harmony-intl-number-format-v3', 'Intl.DurationFormat': '--harmony-intl-duration-format', + 'Intl.Locale-info': '--harmony-intl-locale-info-func', 'FinalizationRegistry': '--harmony-weak-refs-with-cleanup-some', 'WeakRef': '--harmony-weak-refs-with-cleanup-some', 'host-gc-required': '--expose-gc-as=v8GC',