Commit 439c868f authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Define @@toStringTag for Intl namespace

Implement https://github.com/tc39/ecma402/pull/487
Also improve test/intl/toStringTag.js

see also: https://github.com/tc39/test262/pull/2712

Bug: v8:10744
Change-Id: I678876aa21f169a8dfcec8e3ce974978a8847fe0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2315455Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69185}
parent 5277adef
......@@ -2761,6 +2761,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->NewJSObject(isolate_->object_function(), AllocationType::kOld);
JSObject::AddProperty(isolate_, global, "Intl", intl, DONT_ENUM);
// ecma402 #sec-Intl-toStringTag
// The initial value of the @@toStringTag property is the string value
// *"Intl"*.
InstallToStringTag(isolate_, intl, "Intl");
SimpleInstallFunction(isolate(), intl, "getCanonicalLocales",
Builtins::kIntlGetCanonicalLocales, 1, false);
......
......@@ -4,26 +4,21 @@
let descriptor;
descriptor = Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype,
Symbol.toStringTag);
assertEquals("Intl.DateTimeFormat", descriptor.value);
assertFalse(descriptor.writable);
assertFalse(descriptor.enumerable);
assertTrue(descriptor.configurable);
descriptor = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype,
Symbol.toStringTag);
assertEquals("Intl.NumberFormat", descriptor.value);
assertFalse(descriptor.writable);
assertFalse(descriptor.enumerable);
assertTrue(descriptor.configurable);
descriptor = Object.getOwnPropertyDescriptor(Intl.Collator.prototype,
Symbol.toStringTag);
assertEquals("Intl.Collator", descriptor.value);
assertFalse(descriptor.writable);
assertFalse(descriptor.enumerable);
assertTrue(descriptor.configurable);
for (const [obj, tag] of
[[Intl, "Intl"],
[Intl.Collator.prototype, "Intl.Collator"],
[Intl.DateTimeFormat.prototype, "Intl.DateTimeFormat"],
[Intl.DisplayNames.prototype, "Intl.DisplayNames"],
[Intl.Locale.prototype, "Intl.Locale"],
[Intl.ListFormat.prototype, "Intl.ListFormat"],
[Intl.NumberFormat.prototype, "Intl.NumberFormat"],
[Intl.RelativeTimeFormat.prototype, "Intl.RelativeTimeFormat"],
[Intl.PluralRules.prototype, "Intl.PluralRules"],
]) {
descriptor = Object.getOwnPropertyDescriptor(obj,
Symbol.toStringTag);
assertEquals(tag, descriptor.value);
assertFalse(descriptor.writable);
assertFalse(descriptor.enumerable);
assertTrue(descriptor.configurable);
}
......@@ -453,6 +453,9 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=7472
'intl402/NumberFormat/currency-digits': [FAIL],
# http://crbug/v8/10744
'intl402/Intl/builtin': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=7831
'language/statements/generators/generator-created-after-decl-inst': [FAIL],
'language/expressions/generators/generator-created-after-decl-inst': [FAIL],
......
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