Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 90bfdea

Browse files
committed
Bug 1642962: Add toStringTag to Intl prototypes referring to the constructor name. r=jwalden
Implement the changes from <tc39/ecma402#430>. Differential Revision: https://phabricator.services.mozilla.com/D78035
1 parent 29b8477 commit 90bfdea

File tree

8 files changed

+30
-13
lines changed

8 files changed

+30
-13
lines changed

js/src/builtin/intl/Collator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static const JSFunctionSpec collator_methods[] = {
8484

8585
static const JSPropertySpec collator_properties[] = {
8686
JS_SELF_HOSTED_GET("compare", "$Intl_Collator_compare_get", 0),
87-
JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
87+
JS_STRING_SYM_PS(toStringTag, "Intl.Collator", JSPROP_READONLY), JS_PS_END};
8888

8989
static bool Collator(JSContext* cx, unsigned argc, Value* vp);
9090

js/src/builtin/intl/DateTimeFormat.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ static const JSFunctionSpec dateTimeFormat_methods[] = {
9696

9797
static const JSPropertySpec dateTimeFormat_properties[] = {
9898
JS_SELF_HOSTED_GET("format", "$Intl_DateTimeFormat_format_get", 0),
99-
JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
99+
JS_STRING_SYM_PS(toStringTag, "Intl.DateTimeFormat", JSPROP_READONLY),
100+
JS_PS_END};
100101

101102
static bool DateTimeFormat(JSContext* cx, unsigned argc, Value* vp);
102103

js/src/builtin/intl/NumberFormat.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ static const JSFunctionSpec numberFormat_methods[] = {
108108

109109
static const JSPropertySpec numberFormat_properties[] = {
110110
JS_SELF_HOSTED_GET("format", "$Intl_NumberFormat_format_get", 0),
111-
JS_STRING_SYM_PS(toStringTag, "Object", JSPROP_READONLY), JS_PS_END};
111+
JS_STRING_SYM_PS(toStringTag, "Intl.NumberFormat", JSPROP_READONLY),
112+
JS_PS_END};
112113

113114
static bool NumberFormat(JSContext* cx, unsigned argc, Value* vp);
114115

js/src/builtin/intl/PluralRules.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ static const JSFunctionSpec pluralRules_methods[] = {
7878
JS_SELF_HOSTED_FN("select", "Intl_PluralRules_select", 1, 0),
7979
JS_FN(js_toSource_str, pluralRules_toSource, 0, 0), JS_FS_END};
8080

81+
static const JSPropertySpec pluralRules_properties[] = {
82+
JS_STRING_SYM_PS(toStringTag, "Intl.PluralRules", JSPROP_READONLY),
83+
JS_PS_END};
84+
8185
static bool PluralRules(JSContext* cx, unsigned argc, Value* vp);
8286

8387
const ClassSpec PluralRulesObject::classSpec_ = {
@@ -86,7 +90,7 @@ const ClassSpec PluralRulesObject::classSpec_ = {
8690
pluralRules_static_methods,
8791
nullptr,
8892
pluralRules_methods,
89-
nullptr,
93+
pluralRules_properties,
9094
nullptr,
9195
ClassSpec::DontDefineConstructor};
9296

js/src/tests/jstests.list

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,17 @@ skip script test262/built-ins/Promise/all/invoke-resolve-get-error-close.js
715715
skip script test262/built-ins/Promise/race/invoke-resolve-get-error-close.js
716716
skip script test262/built-ins/Promise/allSettled/invoke-resolve-get-error-close.js
717717

718+
# Not yet updated for <https://github.com/tc39/ecma402/pull/430>.
719+
skip script test262/intl402/Collator/instance-class.js
720+
skip script test262/intl402/Collator/prototype/builtin.js
721+
skip script test262/intl402/PluralRules/prototype/builtins.js
722+
skip script test262/intl402/NumberFormat/instance-class.js
723+
skip script test262/intl402/NumberFormat/prototype/builtin.js
724+
skip script test262/intl402/NumberFormat/prototype/toStringTag/configurable.js
725+
skip script test262/intl402/NumberFormat/prototype/toStringTag/prop-desc.js
726+
skip script test262/intl402/DateTimeFormat/instance-class.js
727+
skip script test262/intl402/DateTimeFormat/prototype/builtin.js
728+
718729

719730
##############################################
720731
# Enable Iterator Helpers tests in the shell #

js/src/tests/non262/Intl/Collator/toStringTag.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
var desc = Object.getOwnPropertyDescriptor(Intl.Collator.prototype, Symbol.toStringTag);
88

99
assertEq(desc !== undefined, true);
10-
assertEq(desc.value, "Object");
10+
assertEq(desc.value, "Intl.Collator");
1111
assertEq(desc.writable, false);
1212
assertEq(desc.enumerable, false);
1313
assertEq(desc.configurable, true);
1414

15-
assertEq(Object.prototype.toString.call(Intl.Collator.prototype), "[object Object]");
16-
assertEq(Object.prototype.toString.call(new Intl.Collator), "[object Object]");
15+
assertEq(Object.prototype.toString.call(Intl.Collator.prototype), "[object Intl.Collator]");
16+
assertEq(Object.prototype.toString.call(new Intl.Collator), "[object Intl.Collator]");
1717

1818
Object.defineProperty(Intl.Collator.prototype, Symbol.toStringTag, {value: "Collator"});
1919

js/src/tests/non262/Intl/DateTimeFormat/toStringTag.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
var desc = Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, Symbol.toStringTag);
88

99
assertEq(desc !== undefined, true);
10-
assertEq(desc.value, "Object");
10+
assertEq(desc.value, "Intl.DateTimeFormat");
1111
assertEq(desc.writable, false);
1212
assertEq(desc.enumerable, false);
1313
assertEq(desc.configurable, true);
1414

15-
assertEq(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Object]");
16-
assertEq(Object.prototype.toString.call(new Intl.DateTimeFormat), "[object Object]");
15+
assertEq(Object.prototype.toString.call(Intl.DateTimeFormat.prototype), "[object Intl.DateTimeFormat]");
16+
assertEq(Object.prototype.toString.call(new Intl.DateTimeFormat), "[object Intl.DateTimeFormat]");
1717

1818
Object.defineProperty(Intl.DateTimeFormat.prototype, Symbol.toStringTag, {value: "DateTimeFormat"});
1919

js/src/tests/non262/Intl/NumberFormat/toStringTag.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
var desc = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, Symbol.toStringTag);
88

99
assertEq(desc !== undefined, true);
10-
assertEq(desc.value, "Object");
10+
assertEq(desc.value, "Intl.NumberFormat");
1111
assertEq(desc.writable, false);
1212
assertEq(desc.enumerable, false);
1313
assertEq(desc.configurable, true);
1414

15-
assertEq(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Object]");
16-
assertEq(Object.prototype.toString.call(new Intl.NumberFormat), "[object Object]");
15+
assertEq(Object.prototype.toString.call(Intl.NumberFormat.prototype), "[object Intl.NumberFormat]");
16+
assertEq(Object.prototype.toString.call(new Intl.NumberFormat), "[object Intl.NumberFormat]");
1717

1818
Object.defineProperty(Intl.NumberFormat.prototype, Symbol.toStringTag, {value: "NumberFormat"});
1919

0 commit comments

Comments
 (0)