Changeset 273153 in webkit
- Timestamp:
- Feb 19, 2021 11:38:57 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r273140 r273153 1 2021-02-19 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Do not use toObject for options in new Intl constructors 4 https://bugs.webkit.org/show_bug.cgi?id=222164 5 6 Reviewed by Alexey Shvayka. 7 8 * stress/intl-get-options-not-using-toobject.js: Added. 9 (shouldThrow): 10 1 11 2021-02-19 Caio Lima <ticaiolima@gmail.com> 2 12 -
trunk/JSTests/stress/intl-displaynames.js
r266029 r273153 22 22 if ($vm.icuVersion() >= 61) { 23 23 shouldBe(Intl.DisplayNames.length, 2); 24 shouldThrow(() => new Intl.DisplayNames, `TypeError: undefined is not an object (evaluating 'new Intl.DisplayNames')`);24 shouldThrow(() => new Intl.DisplayNames, `TypeError: type must not be undefined`); 25 25 26 26 // Get display names of region in English -
trunk/Source/JavaScriptCore/ChangeLog
r273152 r273153 1 2021-02-19 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Do not use toObject for options in new Intl constructors 4 https://bugs.webkit.org/show_bug.cgi?id=222164 5 6 Reviewed by Alexey Shvayka. 7 8 New spec change[1] introduced stricter GetOptionsObject for relatively new Intl constructors: Intl.DisplayNames, Intl.ListFormat, and Intl.Segmenter[2]. 9 This does not perform `ToObject`, and instead, 10 11 1. If the input is an undefined, then it returns empty object. 12 2. If the input is an object, then it returns this object. 13 3. Otherwise, throwing a TypeError. 14 15 This patch implements it. 16 17 [1]: https://github.com/tc39/ecma402/pull/538 18 [2]: https://github.com/tc39/proposal-intl-segmenter/issues/132 19 20 * runtime/IntlDisplayNames.cpp: 21 (JSC::IntlDisplayNames::initializeDisplayNames): 22 * runtime/IntlListFormat.cpp: 23 (JSC::IntlListFormat::initializeListFormat): 24 * runtime/IntlObjectInlines.h: 25 (JSC::intlGetOptionsObject): 26 * runtime/IntlSegmenter.cpp: 27 (JSC::IntlSegmenter::initializeSegmenter): 28 1 29 2021-02-19 Mark Lam <mark.lam@apple.com> 2 30 -
trunk/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
r268956 r273153 70 70 RETURN_IF_EXCEPTION(scope, void()); 71 71 72 JSObject* options = optionsValue.toObject(globalObject);72 JSObject* options = intlGetOptionsObject(globalObject, optionsValue); 73 73 RETURN_IF_EXCEPTION(scope, void()); 74 74 -
trunk/Source/JavaScriptCore/runtime/IntlListFormat.cpp
r268956 r273153 92 92 RETURN_IF_EXCEPTION(scope, void()); 93 93 94 JSObject* options; 95 if (optionsValue.isUndefined()) 96 options = constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure()); 97 else { 98 options = optionsValue.toObject(globalObject); 99 RETURN_IF_EXCEPTION(scope, void()); 100 } 94 JSObject* options = intlGetOptionsObject(globalObject, optionsValue); 95 RETURN_IF_EXCEPTION(scope, void()); 101 96 102 97 ResolveLocaleOptions localeOptions; -
trunk/Source/JavaScriptCore/runtime/IntlObjectInlines.h
r266973 r273153 31 31 #include "JSBoundFunction.h" 32 32 #include "JSObject.h" 33 #include "ObjectConstructor.h" 33 34 #include <unicode/ucol.h> 34 35 … … 181 182 } 182 183 184 // https://tc39.es/ecma402/#sec-getoptionsobject 185 inline JSObject* intlGetOptionsObject(JSGlobalObject* globalObject, JSValue options) 186 { 187 VM& vm = globalObject->vm(); 188 auto scope = DECLARE_THROW_SCOPE(vm); 189 if (options.isUndefined()) 190 return constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure()); 191 if (LIKELY(options.isObject())) 192 return asObject(options); 193 throwTypeError(globalObject, scope, "options argument is not an object or undefined"_s); 194 return nullptr; 195 } 196 183 197 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/IntlSegmenter.cpp
r266032 r273153 68 68 RETURN_IF_EXCEPTION(scope, void()); 69 69 70 JSObject* options; 71 if (optionsValue.isUndefined()) 72 options = constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure()); 73 else { 74 options = optionsValue.toObject(globalObject); 75 RETURN_IF_EXCEPTION(scope, void()); 76 } 70 JSObject* options = intlGetOptionsObject(globalObject, optionsValue); 71 RETURN_IF_EXCEPTION(scope, void()); 77 72 78 73 ResolveLocaleOptions localeOptions;
Note: See TracChangeset
for help on using the changeset viewer.