Skip to content

Commit

Permalink
[Intl] Define @@toStringTag for Intl namespace
Browse files Browse the repository at this point in the history
Implement tc39/ecma402#487
Also improve test/intl/toStringTag.js

see also: tc39/test262#2712

Bug: v8:10744
Change-Id: I678876aa21f169a8dfcec8e3ce974978a8847fe0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2315455
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69185}
  • Loading branch information
FrankYFTang authored and Commit Bot committed Aug 1, 2020
1 parent 5277ade commit 439c868
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/init/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
41 changes: 18 additions & 23 deletions test/intl/toStringTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 439c868

Please sign in to comment.