Commit f0633200 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] add supportedLocales for Intl.ListFormat

Bug: v8:7871
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Icabd067f4074169230f21a574aedecf30c5049e4
Reviewed-on: https://chromium-review.googlesource.com/1195077
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55502}
parent 6b66beba
......@@ -4653,6 +4653,9 @@ void Genesis::InitializeGlobal_harmony_intl_list_format() {
list_format_fun->shared()->set_length(0);
list_format_fun->shared()->DontAdaptArguments();
SimpleInstallFunction(isolate(), list_format_fun, "supportedLocalesOf",
Builtins::kListFormatSupportedLocalesOf, 1, false);
// Setup %ListFormatPrototype%.
Handle<JSObject> prototype(
JSObject::cast(list_format_fun->instance_prototype()), isolate());
......
......@@ -1353,6 +1353,8 @@ namespace internal {
/* ecma402 #sec-intl-list-format.prototype.formattoparts */ \
TFJ(ListFormatPrototypeFormatToParts, \
SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ecma402 #sec-intl.ListFormat.supportedlocalesof */ \
CPP(ListFormatSupportedLocalesOf) \
/* ecma402 #sec-intl-locale-constructor */ \
CPP(LocaleConstructor) \
CPP(LocalePrototypeLanguage) \
......
......@@ -744,6 +744,12 @@ BUILTIN(ListFormatPrototypeResolvedOptions) {
return *JSListFormat::ResolvedOptions(isolate, format_holder);
}
BUILTIN(ListFormatSupportedLocalesOf) {
HandleScope scope(isolate);
RETURN_RESULT_OR_FAILURE(
isolate, SupportedLocalesOfCommon(isolate, "listformat", args));
}
namespace {
MaybeHandle<JSLocale> CreateLocale(Isolate* isolate,
......
// Copyright 2018 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-list-format
assertEquals(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Intl.ListFormat.supportedLocalesOf should be a function");
var undef = Intl.ListFormat.supportedLocalesOf();
assertEquals([], undef);
var empty = Intl.ListFormat.supportedLocalesOf([]);
assertEquals([], empty);
var strLocale = Intl.ListFormat.supportedLocalesOf('sr');
assertEquals('sr', strLocale[0]);
var multiLocale = ['sr-Thai-RS', 'de', 'zh-CN'];
assertEquals(multiLocale, Intl.ListFormat.supportedLocalesOf(multiLocale));
// Copyright 2018 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-relative-time-format
assertEquals(typeof Intl.RelativeTimeFormat.supportedLocalesOf, "function",
"Intl.RelativeTimeFormat.supportedLocalesOf should be a function");
var undef = Intl.RelativeTimeFormat.supportedLocalesOf();
assertEquals([], undef);
var empty = Intl.RelativeTimeFormat.supportedLocalesOf([]);
assertEquals([], empty);
var strLocale = Intl.RelativeTimeFormat.supportedLocalesOf('sr');
assertEquals('sr', strLocale[0]);
var multiLocale = ['sr-Thai-RS', 'de', 'zh-CN'];
assertEquals(multiLocale, Intl.RelativeTimeFormat.supportedLocalesOf(multiLocale));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment