Skip to content

Commit

Permalink
Define Intl[Symbol.toStringTag]
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=215715

Reviewed by Ross Kirsling.

JSTests:

* stress/intl-object.js:
* test262/expectations.yaml: Mark 4 test cases as passing.

Source/JavaScriptCore:

This patch utilizes JSC_TO_STRING_TAG_WITHOUT_TRANSITION() to define Symbol.toStringTag
on Intl namespace object, implementing the recent spec change [1] and aligning JSC with V8.
Also, adds inherits() ASSERT to match (most of) the other built-ins.

[1]: tc39/ecma402#487

* runtime/IntlObject.cpp:
(JSC::IntlObject::finishCreation):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@266015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Aug 21, 2020
1 parent 2e5eed4 commit 2275634
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
10 changes: 10 additions & 0 deletions JSTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2020-08-21 Alexey Shvayka <[email protected]>

Define Intl[Symbol.toStringTag]
https://bugs.webkit.org/show_bug.cgi?id=215715

Reviewed by Ross Kirsling.

* stress/intl-object.js:
* test262/expectations.yaml: Mark 4 test cases as passing.

2020-08-21 Alexey Shvayka <[email protected]>

Function.prototype.bind should not clamp "length" to int32
Expand Down
2 changes: 1 addition & 1 deletion JSTests/stress/intl-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function shouldThrow(func, errorType) {
// The Intl object is a single ordinary object.
shouldBe(Intl instanceof Object, true);
shouldBe(typeof Intl, 'object');
shouldBe(Object.prototype.toString.call(Intl), '[object Object]');
shouldBe(Object.prototype.toString.call(Intl), '[object Intl]');

// The value of the [[Prototype]] internal slot of the Intl object is the intrinsic object %ObjectPrototype%.
shouldBe(Object.getPrototypeOf(Intl), Object.prototype);
Expand Down
6 changes: 0 additions & 6 deletions JSTests/test262/expectations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1620,12 +1620,6 @@ test/intl402/Intl/getCanonicalLocales/unicode-ext-canonicalize-yes-to-true.js:
test/intl402/Intl/getCanonicalLocales/unicode-ext-key-with-digit.js:
default: 'Test262Error: Expected a RangeError to be thrown but no exception was thrown at all'
strict mode: 'Test262Error: Expected a RangeError to be thrown but no exception was thrown at all'
test/intl402/Intl/toStringTag/toString.js:
default: 'Test262Error: Expected SameValue(«[object Object]», «[object Intl]») to be true'
strict mode: 'Test262Error: Expected SameValue(«[object Object]», «[object Intl]») to be true'
test/intl402/Intl/toStringTag/toStringTag.js:
default: 'Test262Error: obj should have an own property Symbol(Symbol.toStringTag)'
strict mode: 'Test262Error: obj should have an own property Symbol(Symbol.toStringTag)'
test/intl402/Locale/constructor-apply-options-canonicalizes-twice.js:
default: 'Test262Error: Expected SameValue(«ru-Armn-SU», «ru-Armn-AM») to be true'
strict mode: 'Test262Error: Expected SameValue(«ru-Armn-SU», «ru-Armn-AM») to be true'
Expand Down
16 changes: 16 additions & 0 deletions Source/JavaScriptCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2020-08-21 Alexey Shvayka <[email protected]>

Define Intl[Symbol.toStringTag]
https://bugs.webkit.org/show_bug.cgi?id=215715

Reviewed by Ross Kirsling.

This patch utilizes JSC_TO_STRING_TAG_WITHOUT_TRANSITION() to define Symbol.toStringTag
on Intl namespace object, implementing the recent spec change [1] and aligning JSC with V8.
Also, adds inherits() ASSERT to match (most of) the other built-ins.

[1]: https://github.com/tc39/ecma402/pull/487

* runtime/IntlObject.cpp:
(JSC::IntlObject::finishCreation):

2020-08-21 Alexey Shvayka <[email protected]>

Function.prototype.bind should not clamp "length" to int32
Expand Down
4 changes: 3 additions & 1 deletion Source/JavaScriptCore/runtime/IntlObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct MatcherResult {
size_t extensionIndex { 0 };
};

const ClassInfo IntlObject::s_info = { "Object", &Base::s_info, &intlObjectTable, nullptr, CREATE_METHOD_TABLE(IntlObject) };
const ClassInfo IntlObject::s_info = { "Intl", &Base::s_info, &intlObjectTable, nullptr, CREATE_METHOD_TABLE(IntlObject) };

void UFieldPositionIteratorDeleter::operator()(UFieldPositionIterator* iterator) const
{
Expand All @@ -163,6 +163,8 @@ IntlObject* IntlObject::create(VM& vm, JSGlobalObject* globalObject, Structure*
void IntlObject::finishCreation(VM& vm, JSGlobalObject*)
{
Base::finishCreation(vm);
ASSERT(inherits(vm, info()));
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
if (Options::useIntlDisplayNames())
putDirectWithoutTransition(vm, vm.propertyNames->DisplayNames, createDisplayNamesConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
Expand Down

0 comments on commit 2275634

Please sign in to comment.