Bug 1642962: Add toStringTag to Intl prototypes referring to the constructor name. r=jwalden
authorAndré Bargull <andre.bargull@gmail.com>
Thu, 04 Jun 2020 11:24:02 +0000
changeset 597963 fd4400f508cc99e96d6a1a129480d5e59b667128
parent 597962 3f3c444a38ad7f3c7ae953cb2778b0fef2e63307
child 597964 001e62003bebee9a0186c03c6432383305d03a7a
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1642962
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1642962: Add toStringTag to Intl prototypes referring to the constructor name. r=jwalden Implement the changes from <https://github.com/tc39/ecma402/pull/430>. Differential Revision: https://phabricator.services.mozilla.com/D78035
js/src/builtin/intl/Collator.cpp
js/src/builtin/intl/DateTimeFormat.cpp
js/src/builtin/intl/NumberFormat.cpp
js/src/builtin/intl/PluralRules.cpp
js/src/tests/jstests.list
js/src/tests/non262/Intl/Collator/toStringTag.js
js/src/tests/non262/Intl/DateTimeFormat/toStringTag.js
js/src/tests/non262/Intl/NumberFormat/toStringTag.js
--- a/js/src/builtin/intl/Collator.cpp
+++ b/js/src/builtin/intl/Collator.cpp
@@ -79,17 +79,17 @@ static const JSFunctionSpec collator_sta
     JS_FS_END};
 
 static const JSFunctionSpec collator_methods[] = {
     JS_SELF_HOSTED_FN("resolvedOptions", "Intl_Collator_resolvedOptions", 0, 0),
     JS_FN(js_toSource_str, collator_toSource, 0, 0), JS_FS_END};
 
 static const JSPropertySpec collator_properties[] = {
     JS_SELF_HOSTED_GET("compare", "$Intl_Collator_compare_get", 0),
-    JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
+    JS_STRING_SYM_PS(toStringTag, "Intl.Collator", JSPROP_READONLY), JS_PS_END};
 
 static bool Collator(JSContext* cx, unsigned argc, Value* vp);
 
 const ClassSpec CollatorObject::classSpec_ = {
     GenericCreateConstructor<Collator, 0, gc::AllocKind::FUNCTION>,
     GenericCreatePrototype<CollatorObject>,
     collator_static_methods,
     nullptr,
--- a/js/src/builtin/intl/DateTimeFormat.cpp
+++ b/js/src/builtin/intl/DateTimeFormat.cpp
@@ -91,17 +91,18 @@ static const JSFunctionSpec dateTimeForm
     JS_SELF_HOSTED_FN("resolvedOptions", "Intl_DateTimeFormat_resolvedOptions",
                       0, 0),
     JS_SELF_HOSTED_FN("formatToParts", "Intl_DateTimeFormat_formatToParts", 1,
                       0),
     JS_FN(js_toSource_str, dateTimeFormat_toSource, 0, 0), JS_FS_END};
 
 static const JSPropertySpec dateTimeFormat_properties[] = {
     JS_SELF_HOSTED_GET("format", "$Intl_DateTimeFormat_format_get", 0),
-    JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
+    JS_STRING_SYM_PS(toStringTag, "Intl.DateTimeFormat", JSPROP_READONLY),
+    JS_PS_END};
 
 static bool DateTimeFormat(JSContext* cx, unsigned argc, Value* vp);
 
 const ClassSpec DateTimeFormatObject::classSpec_ = {
     GenericCreateConstructor<DateTimeFormat, 0, gc::AllocKind::FUNCTION>,
     GenericCreatePrototype<DateTimeFormatObject>,
     dateTimeFormat_static_methods,
     nullptr,
--- a/js/src/builtin/intl/NumberFormat.cpp
+++ b/js/src/builtin/intl/NumberFormat.cpp
@@ -103,17 +103,18 @@ static const JSFunctionSpec numberFormat
 static const JSFunctionSpec numberFormat_methods[] = {
     JS_SELF_HOSTED_FN("resolvedOptions", "Intl_NumberFormat_resolvedOptions", 0,
                       0),
     JS_SELF_HOSTED_FN("formatToParts", "Intl_NumberFormat_formatToParts", 1, 0),
     JS_FN(js_toSource_str, numberFormat_toSource, 0, 0), JS_FS_END};
 
 static const JSPropertySpec numberFormat_properties[] = {
     JS_SELF_HOSTED_GET("format", "$Intl_NumberFormat_format_get", 0),
-    JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
+    JS_STRING_SYM_PS(toStringTag, "Intl.NumberFormat", JSPROP_READONLY),
+    JS_PS_END};
 
 static bool NumberFormat(JSContext* cx, unsigned argc, Value* vp);
 
 const ClassSpec NumberFormatObject::classSpec_ = {
     GenericCreateConstructor<NumberFormat, 0, gc::AllocKind::FUNCTION>,
     GenericCreatePrototype<NumberFormatObject>,
     numberFormat_static_methods,
     nullptr,
--- a/js/src/builtin/intl/PluralRules.cpp
+++ b/js/src/builtin/intl/PluralRules.cpp
@@ -73,25 +73,29 @@ static const JSFunctionSpec pluralRules_
     JS_FS_END};
 
 static const JSFunctionSpec pluralRules_methods[] = {
     JS_SELF_HOSTED_FN("resolvedOptions", "Intl_PluralRules_resolvedOptions", 0,
                       0),
     JS_SELF_HOSTED_FN("select", "Intl_PluralRules_select", 1, 0),
     JS_FN(js_toSource_str, pluralRules_toSource, 0, 0), JS_FS_END};
 
+static const JSPropertySpec pluralRules_properties[] = {
+    JS_STRING_SYM_PS(toStringTag, "Intl.PluralRules", JSPROP_READONLY),
+    JS_PS_END};
+
 static bool PluralRules(JSContext* cx, unsigned argc, Value* vp);
 
 const ClassSpec PluralRulesObject::classSpec_ = {
     GenericCreateConstructor<PluralRules, 0, gc::AllocKind::FUNCTION>,
     GenericCreatePrototype<PluralRulesObject>,
     pluralRules_static_methods,
     nullptr,
     pluralRules_methods,
-    nullptr,
+    pluralRules_properties,
     nullptr,
     ClassSpec::DontDefineConstructor};
 
 /**
  * PluralRules constructor.
  * Spec: ECMAScript 402 API, PluralRules, 13.2.1
  */
 static bool PluralRules(JSContext* cx, unsigned argc, Value* vp) {
--- a/js/src/tests/jstests.list
+++ b/js/src/tests/jstests.list
@@ -710,16 +710,27 @@ skip script test262/intl402/NumberFormat
 skip script test262/intl402/NumberFormat/prototype/format/signDisplay-currency-en-US.js
 
 # Not yet updated for <https://github.com/tc39/ecma262/pull/1912>.
 skip script test262/built-ins/Promise/any/invoke-resolve-get-error-close.js
 skip script test262/built-ins/Promise/all/invoke-resolve-get-error-close.js
 skip script test262/built-ins/Promise/race/invoke-resolve-get-error-close.js
 skip script test262/built-ins/Promise/allSettled/invoke-resolve-get-error-close.js
 
+# Not yet updated for <https://github.com/tc39/ecma402/pull/430>.
+skip script test262/intl402/Collator/instance-class.js
+skip script test262/intl402/Collator/prototype/builtin.js
+skip script test262/intl402/PluralRules/prototype/builtins.js
+skip script test262/intl402/NumberFormat/instance-class.js
+skip script test262/intl402/NumberFormat/prototype/builtin.js
+skip script test262/intl402/NumberFormat/prototype/toStringTag/configurable.js
+skip script test262/intl402/NumberFormat/prototype/toStringTag/prop-desc.js
+skip script test262/intl402/DateTimeFormat/instance-class.js
+skip script test262/intl402/DateTimeFormat/prototype/builtin.js
+
 
 ##############################################
 # Enable Iterator Helpers tests in the shell #
 ##############################################
 shell-option(--enable-iterator-helpers) script non262/Iterator/iterator.js
 shell-option(--enable-iterator-helpers) script non262/Iterator/length.js
 shell-option(--enable-iterator-helpers) script non262/Iterator/name.js
 shell-option(--enable-iterator-helpers) script non262/Iterator/proto.js
--- a/js/src/tests/non262/Intl/Collator/toStringTag.js
+++ b/js/src/tests/non262/Intl/Collator/toStringTag.js
@@ -2,23 +2,23 @@
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var desc = Object.getOwnPropertyDescriptor(Intl.Collator.prototype, Symbol.toStringTag);
 
 assertEq(desc !== undefined, true);
-assertEq(desc.value, "Object");
+assertEq(desc.value, "Intl.Collator");
 assertEq(desc.writable, false);
 assertEq(desc.enumerable, false);
 assertEq(desc.configurable, true);
 
-assertEq(Object.prototype.toString.call(Intl.Collator.prototype), "[object Object]");
-assertEq(Object.prototype.toString.call(new Intl.Collator), "[object Object]");
+assertEq(Object.prototype.toString.call(Intl.Collator.prototype), "[object Intl.Collator]");
+assertEq(Object.prototype.toString.call(new Intl.Collator), "[object Intl.Collator]");
 
 Object.defineProperty(Intl.Collator.prototype, Symbol.toStringTag, {value: "Collator"});
 
 assertEq(Object.prototype.toString.call(Intl.Collator.prototype), "[object Collator]");
 assertEq(Object.prototype.toString.call(new Intl.Collator), "[object Collator]");
 
 delete Intl.Collator.prototype[Symbol.toStringTag];
 
--- a/js/src/tests/non262/Intl/DateTimeFormat/toStringTag.js
+++ b/js/src/tests/non262/Intl/DateTimeFormat/toStringTag.js
@@ -2,23 +2,23 @@
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var desc = Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, Symbol.toStringTag);
 
 assertEq(desc !== undefined, true);
-assertEq(desc.value, "Object");
+assertEq(desc.value, "Intl.DateTimeFormat");
 assertEq(desc.writable, false);
 assertEq(desc.enumerable, false);
 assertEq(desc.configurable, true);
 
-assertEq(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Object]");
-assertEq(Object.prototype.toString.call(new Intl.DateTimeFormat), "[object Object]");
+assertEq(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Intl.DateTimeFormat]");
+assertEq(Object.prototype.toString.call(new Intl.DateTimeFormat), "[object Intl.DateTimeFormat]");
 
 Object.defineProperty(Intl.DateTimeFormat.prototype, Symbol.toStringTag, {value: "DateTimeFormat"});
 
 assertEq(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object DateTimeFormat]");
 assertEq(Object.prototype.toString.call(new Intl.DateTimeFormat), "[object DateTimeFormat]");
 
 delete Intl.DateTimeFormat.prototype[Symbol.toStringTag];
 
--- a/js/src/tests/non262/Intl/NumberFormat/toStringTag.js
+++ b/js/src/tests/non262/Intl/NumberFormat/toStringTag.js
@@ -2,23 +2,23 @@
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var desc = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, Symbol.toStringTag);
 
 assertEq(desc !== undefined, true);
-assertEq(desc.value, "Object");
+assertEq(desc.value, "Intl.NumberFormat");
 assertEq(desc.writable, false);
 assertEq(desc.enumerable, false);
 assertEq(desc.configurable, true);
 
-assertEq(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Object]");
-assertEq(Object.prototype.toString.call(new Intl.NumberFormat), "[object Object]");
+assertEq(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Intl.NumberFormat]");
+assertEq(Object.prototype.toString.call(new Intl.NumberFormat), "[object Intl.NumberFormat]");
 
 Object.defineProperty(Intl.NumberFormat.prototype, Symbol.toStringTag, {value: "NumberFormat"});
 
 assertEq(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object NumberFormat]");
 assertEq(Object.prototype.toString.call(new Intl.NumberFormat), "[object NumberFormat]");
 
 delete Intl.NumberFormat.prototype[Symbol.toStringTag];