From 439c868ffa04ecd06c91b57e3d536414532dbeaf Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 30 Jul 2020 16:31:27 -0700 Subject: [PATCH] [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/+/2315455 Reviewed-by: Shu-yu Guo Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/master@{#69185} --- src/init/bootstrapper.cc | 5 +++++ test/intl/toStringTag.js | 41 ++++++++++++++++--------------------- test/test262/test262.status | 3 +++ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/init/bootstrapper.cc b/src/init/bootstrapper.cc index 5139c32f7c3b..3a4dc40c982a 100644 --- a/src/init/bootstrapper.cc +++ b/src/init/bootstrapper.cc @@ -2761,6 +2761,11 @@ void Genesis::InitializeGlobal(Handle 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); diff --git a/test/intl/toStringTag.js b/test/intl/toStringTag.js index 9f1d8e7930e6..4cc54455e131 100644 --- a/test/intl/toStringTag.js +++ b/test/intl/toStringTag.js @@ -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); +} diff --git a/test/test262/test262.status b/test/test262/test262.status index eec1cb65c1de..dded88081c4c 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -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],