Skip to content

Commit 439c868

Browse files
FrankYFTangCommit Bot
authored and
Commit Bot
committed
[Intl] Define @@toStringTag for Intl namespace
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 <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/master@{#69185}
1 parent 5277ade commit 439c868

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

src/init/bootstrapper.cc

+5
Original file line numberDiff line numberDiff line change
@@ -2761,6 +2761,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
27612761
factory->NewJSObject(isolate_->object_function(), AllocationType::kOld);
27622762
JSObject::AddProperty(isolate_, global, "Intl", intl, DONT_ENUM);
27632763

2764+
// ecma402 #sec-Intl-toStringTag
2765+
// The initial value of the @@toStringTag property is the string value
2766+
// *"Intl"*.
2767+
InstallToStringTag(isolate_, intl, "Intl");
2768+
27642769
SimpleInstallFunction(isolate(), intl, "getCanonicalLocales",
27652770
Builtins::kIntlGetCanonicalLocales, 1, false);
27662771

test/intl/toStringTag.js

+18-23
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@
44

55
let descriptor;
66

7-
descriptor = Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype,
8-
Symbol.toStringTag);
9-
10-
assertEquals("Intl.DateTimeFormat", descriptor.value);
11-
assertFalse(descriptor.writable);
12-
assertFalse(descriptor.enumerable);
13-
assertTrue(descriptor.configurable);
14-
15-
descriptor = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype,
16-
Symbol.toStringTag);
17-
18-
assertEquals("Intl.NumberFormat", descriptor.value);
19-
assertFalse(descriptor.writable);
20-
assertFalse(descriptor.enumerable);
21-
assertTrue(descriptor.configurable);
22-
23-
descriptor = Object.getOwnPropertyDescriptor(Intl.Collator.prototype,
24-
Symbol.toStringTag);
25-
26-
assertEquals("Intl.Collator", descriptor.value);
27-
assertFalse(descriptor.writable);
28-
assertFalse(descriptor.enumerable);
29-
assertTrue(descriptor.configurable);
7+
for (const [obj, tag] of
8+
[[Intl, "Intl"],
9+
[Intl.Collator.prototype, "Intl.Collator"],
10+
[Intl.DateTimeFormat.prototype, "Intl.DateTimeFormat"],
11+
[Intl.DisplayNames.prototype, "Intl.DisplayNames"],
12+
[Intl.Locale.prototype, "Intl.Locale"],
13+
[Intl.ListFormat.prototype, "Intl.ListFormat"],
14+
[Intl.NumberFormat.prototype, "Intl.NumberFormat"],
15+
[Intl.RelativeTimeFormat.prototype, "Intl.RelativeTimeFormat"],
16+
[Intl.PluralRules.prototype, "Intl.PluralRules"],
17+
]) {
18+
descriptor = Object.getOwnPropertyDescriptor(obj,
19+
Symbol.toStringTag);
20+
assertEquals(tag, descriptor.value);
21+
assertFalse(descriptor.writable);
22+
assertFalse(descriptor.enumerable);
23+
assertTrue(descriptor.configurable);
24+
}

test/test262/test262.status

+3
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@
453453
# https://bugs.chromium.org/p/v8/issues/detail?id=7472
454454
'intl402/NumberFormat/currency-digits': [FAIL],
455455

456+
# http://crbug/v8/10744
457+
'intl402/Intl/builtin': [FAIL],
458+
456459
# https://bugs.chromium.org/p/v8/issues/detail?id=7831
457460
'language/statements/generators/generator-created-after-decl-inst': [FAIL],
458461
'language/expressions/generators/generator-created-after-decl-inst': [FAIL],

0 commit comments

Comments
 (0)