Changeset 259822 in webkit
- Timestamp:
- Apr 9, 2020, 1:40:38 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/test262/expectations.yaml (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ProxyObject.cpp (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r259807 r259822 1 2020-04-09 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 ProxyObject::defineOwnProperty() should conditionally throw on falsy trap result 4 https://bugs.webkit.org/show_bug.cgi?id=210267 5 6 Reviewed by Ross Kirsling. 7 8 * test262/expectations.yaml: Mark 2 test cases as passing. 9 1 10 2020-04-09 Saam Barati <sbarati@apple.com> 2 11 -
trunk/JSTests/test262/expectations.yaml
r259800 r259822 1250 1250 default: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy" 1251 1251 strict mode: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy" 1252 test/built-ins/Proxy/defineProperty/trap-is-undefined-target-is-proxy.js:1253 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'1254 strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'1255 1252 test/built-ins/Proxy/ownKeys/trap-is-undefined-target-is-proxy.js: 1256 1253 default: 'Test262Error: Expected [length, foo, 0, Symbol()] and [Symbol(), length, foo, 0] to have the same contents. ' -
trunk/Source/JavaScriptCore/ChangeLog
r259810 r259822 1 2020-04-09 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 ProxyObject::defineOwnProperty() should conditionally throw on falsy trap result 4 https://bugs.webkit.org/show_bug.cgi?id=210267 5 6 Reviewed by Ross Kirsling. 7 8 This change adds conditional TypeError for falsy trap result [1], like there is in 9 ProxyObject::performPut(), aligning JSC with V8 and SpiderMonkey. Also replaces 10 throwVMTypeError() calls which results are unused with throwTypeError(). 11 12 [1]: https://tc39.es/ecma262/#sec-definepropertyorthrow (step 4) 13 14 * runtime/ProxyObject.cpp: 15 (JSC::ProxyObject::performDefineOwnProperty) 16 1 17 2020-04-09 Devin Rousso <drousso@apple.com> 2 18 -
trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp
r259676 r259822 227 227 JSValue handlerValue = this->handler(); 228 228 if (handlerValue.isNull()) { 229 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);229 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 230 230 return false; 231 231 } … … 247 247 248 248 if (!trapResult.isUndefined() && !trapResult.isObject()) { 249 throw VMTypeError(globalObject, scope, "result of 'getOwnPropertyDescriptor' call should either be an Object or undefined"_s);249 throwTypeError(globalObject, scope, "result of 'getOwnPropertyDescriptor' call should either be an Object or undefined"_s); 250 250 return false; 251 251 } … … 259 259 return false; 260 260 if (!targetPropertyDescriptor.configurable()) { 261 throw VMTypeError(globalObject, scope, "When the result of 'getOwnPropertyDescriptor' is undefined the target must be configurable"_s);261 throwTypeError(globalObject, scope, "When the result of 'getOwnPropertyDescriptor' is undefined the target must be configurable"_s); 262 262 return false; 263 263 } … … 265 265 RETURN_IF_EXCEPTION(scope, false); 266 266 if (!isExtensible) { 267 throw VMTypeError(globalObject, scope, "When 'getOwnPropertyDescriptor' returns undefined, the 'target' of a Proxy should be extensible"_s);267 throwTypeError(globalObject, scope, "When 'getOwnPropertyDescriptor' returns undefined, the 'target' of a Proxy should be extensible"_s); 268 268 return false; 269 269 } … … 282 282 RETURN_IF_EXCEPTION(scope, false); 283 283 if (!valid) { 284 throw VMTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' fails the IsCompatiblePropertyDescriptor test"_s);284 throwTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' fails the IsCompatiblePropertyDescriptor test"_s); 285 285 return false; 286 286 } … … 288 288 if (!trapResultAsDescriptor.configurable()) { 289 289 if (!isTargetPropertyDescriptorDefined || targetPropertyDescriptor.configurable()) { 290 throw VMTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' can't be non-configurable when the 'target' doesn't have it as an own property or if it is a configurable own property on 'target'"_s);290 throwTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' can't be non-configurable when the 'target' doesn't have it as an own property or if it is a configurable own property on 'target'"_s); 291 291 return false; 292 292 } 293 293 if (trapResultAsDescriptor.writablePresent() && !trapResultAsDescriptor.writable() && targetPropertyDescriptor.writable()) { 294 throw VMTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' can't be non-configurable and non-writable when the target's property is writable"_s);294 throwTypeError(globalObject, scope, "Result from 'getOwnPropertyDescriptor' can't be non-configurable and non-writable when the target's property is writable"_s); 295 295 return false; 296 296 } … … 331 331 JSValue handlerValue = this->handler(); 332 332 if (handlerValue.isNull()) { 333 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);333 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 334 334 return false; 335 335 } … … 359 359 if (isPropertyDescriptorDefined) { 360 360 if (!descriptor.configurable()) { 361 throw VMTypeError(globalObject, scope, "Proxy 'has' must return 'true' for non-configurable properties"_s);361 throwTypeError(globalObject, scope, "Proxy 'has' must return 'true' for non-configurable properties"_s); 362 362 return false; 363 363 } … … 365 365 RETURN_IF_EXCEPTION(scope, false); 366 366 if (!isExtensible) { 367 throw VMTypeError(globalObject, scope, "Proxy 'has' must return 'true' for a non-extensible 'target' object with a configurable property"_s);367 throwTypeError(globalObject, scope, "Proxy 'has' must return 'true' for a non-extensible 'target' object with a configurable property"_s); 368 368 return false; 369 369 } … … 434 434 JSValue handlerValue = this->handler(); 435 435 if (handlerValue.isNull()) { 436 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);436 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 437 437 return false; 438 438 } … … 459 459 if (!trapResultAsBool) { 460 460 if (shouldThrow) 461 throw VMTypeError(globalObject, scope, makeString("Proxy object's 'set' trap returned falsy value for property '", String(propertyName.uid()), "'"));461 throwTypeError(globalObject, scope, makeString("Proxy object's 'set' trap returned falsy value for property '", String(propertyName.uid()), "'")); 462 462 return false; 463 463 } … … 471 471 RETURN_IF_EXCEPTION(scope, false); 472 472 if (!isSame) { 473 throw VMTypeError(globalObject, scope, "Proxy handler's 'set' on a non-configurable and non-writable property on 'target' should either return false or be the same value already on the 'target'"_s);473 throwTypeError(globalObject, scope, "Proxy handler's 'set' on a non-configurable and non-writable property on 'target' should either return false or be the same value already on the 'target'"_s); 474 474 return false; 475 475 } 476 476 } else if (descriptor.isAccessorDescriptor() && !descriptor.configurable() && descriptor.setter().isUndefined()) { 477 throw VMTypeError(globalObject, scope, "Proxy handler's 'set' method on a non-configurable accessor property without a setter should return false"_s);477 throwTypeError(globalObject, scope, "Proxy handler's 'set' method on a non-configurable accessor property without a setter should return false"_s); 478 478 return false; 479 479 } … … 639 639 JSValue handlerValue = this->handler(); 640 640 if (handlerValue.isNull()) { 641 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);641 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 642 642 return false; 643 643 } … … 670 670 if (result) { 671 671 if (!descriptor.configurable()) { 672 throw VMTypeError(globalObject, scope, "Proxy handler's 'deleteProperty' method should return false when the target's property is not configurable"_s);672 throwTypeError(globalObject, scope, "Proxy handler's 'deleteProperty' method should return false when the target's property is not configurable"_s); 673 673 return false; 674 674 } … … 676 676 RETURN_IF_EXCEPTION(scope, false); 677 677 if (!targetIsExtensible) { 678 throw VMTypeError(globalObject, scope, "Proxy handler's 'deleteProperty' method should return false when the target has property and is not extensible"_s);678 throwTypeError(globalObject, scope, "Proxy handler's 'deleteProperty' method should return false when the target has property and is not extensible"_s); 679 679 return false; 680 680 } … … 721 721 JSValue handlerValue = this->handler(); 722 722 if (handlerValue.isNull()) { 723 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);723 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 724 724 return false; 725 725 } … … 747 747 RETURN_IF_EXCEPTION(scope, false); 748 748 if (targetIsExtensible) { 749 throw VMTypeError(globalObject, scope, "Proxy's 'preventExtensions' trap returned true even though its target is extensible. It should have returned false"_s);749 throwTypeError(globalObject, scope, "Proxy's 'preventExtensions' trap returned true even though its target is extensible. It should have returned false"_s); 750 750 return false; 751 751 } … … 773 773 JSValue handlerValue = this->handler(); 774 774 if (handlerValue.isNull()) { 775 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);775 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 776 776 return false; 777 777 } … … 802 802 if (isTargetExtensible) { 803 803 ASSERT(!trapResultAsBool); 804 throw VMTypeError(globalObject, scope, "Proxy object's 'isExtensible' trap returned false when the target is extensible. It should have returned true"_s);804 throwTypeError(globalObject, scope, "Proxy object's 'isExtensible' trap returned false when the target is extensible. It should have returned true"_s); 805 805 } else { 806 806 ASSERT(!isTargetExtensible); 807 807 ASSERT(trapResultAsBool); 808 throw VMTypeError(globalObject, scope, "Proxy object's 'isExtensible' trap returned true when the target is non-extensible. It should have returned false"_s);808 throwTypeError(globalObject, scope, "Proxy object's 'isExtensible' trap returned true when the target is non-extensible. It should have returned false"_s); 809 809 } 810 810 } … … 839 839 JSValue handlerValue = this->handler(); 840 840 if (handlerValue.isNull()) { 841 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);841 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 842 842 return false; 843 843 } … … 866 866 RETURN_IF_EXCEPTION(scope, false); 867 867 868 if (!trapResultAsBool) 869 return false; 868 if (!trapResultAsBool) { 869 if (shouldThrow) 870 throwTypeError(globalObject, scope, makeString("Proxy's 'defineProperty' trap returned falsy value for property '", String(propertyName.uid()), "'")); 871 return false; 872 } 870 873 871 874 PropertyDescriptor targetDescriptor; … … 879 882 if (!isTargetDescriptorDefined) { 880 883 if (!targetIsExtensible) { 881 throw VMTypeError(globalObject, scope, "Proxy's 'defineProperty' trap returned true even though getOwnPropertyDescriptor of the Proxy's target returned undefined and the target is non-extensible"_s);884 throwTypeError(globalObject, scope, "Proxy's 'defineProperty' trap returned true even though getOwnPropertyDescriptor of the Proxy's target returned undefined and the target is non-extensible"_s); 882 885 return false; 883 886 } 884 887 if (settingConfigurableToFalse) { 885 throw VMTypeError(globalObject, scope, "Proxy's 'defineProperty' trap returned true for a non-configurable field even though getOwnPropertyDescriptor of the Proxy's target returned undefined"_s);888 throwTypeError(globalObject, scope, "Proxy's 'defineProperty' trap returned true for a non-configurable field even though getOwnPropertyDescriptor of the Proxy's target returned undefined"_s); 886 889 return false; 887 890 } … … 897 900 RETURN_IF_EXCEPTION(scope, false); 898 901 if (!isCompatibleDescriptor) { 899 throw VMTypeError(globalObject, scope, "Proxy's 'defineProperty' trap did not define a property on its target that is compatible with the trap's input descriptor"_s);902 throwTypeError(globalObject, scope, "Proxy's 'defineProperty' trap did not define a property on its target that is compatible with the trap's input descriptor"_s); 900 903 return false; 901 904 } 902 905 if (settingConfigurableToFalse && targetDescriptor.configurable()) { 903 throw VMTypeError(globalObject, scope, "Proxy's 'defineProperty' trap did not define a non-configurable property on its target even though the input descriptor to the trap said it must do so"_s);906 throwTypeError(globalObject, scope, "Proxy's 'defineProperty' trap did not define a non-configurable property on its target even though the input descriptor to the trap said it must do so"_s); 904 907 return false; 905 908 } … … 932 935 JSValue handlerValue = this->handler(); 933 936 if (handlerValue.isNull()) { 934 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);937 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 935 938 return; 936 939 } … … 1024 1027 for (UniquedStringImpl* impl : targetNonConfigurableKeys) { 1025 1028 if (removeIfContainedInUncheckedResultKeys(impl) == IsNotContainedIn) { 1026 throw VMTypeError(globalObject, scope, makeString("Proxy object's 'target' has the non-configurable property '", String(impl), "' that was not in the result from the 'ownKeys' trap"));1029 throwTypeError(globalObject, scope, makeString("Proxy object's 'target' has the non-configurable property '", String(impl), "' that was not in the result from the 'ownKeys' trap")); 1027 1030 return; 1028 1031 } … … 1032 1035 for (UniquedStringImpl* impl : targetConfigurableKeys) { 1033 1036 if (removeIfContainedInUncheckedResultKeys(impl) == IsNotContainedIn) { 1034 throw VMTypeError(globalObject, scope, makeString("Proxy object's non-extensible 'target' has configurable property '", String(impl), "' that was not in the result from the 'ownKeys' trap"));1037 throwTypeError(globalObject, scope, makeString("Proxy object's non-extensible 'target' has configurable property '", String(impl), "' that was not in the result from the 'ownKeys' trap")); 1035 1038 return; 1036 1039 } … … 1038 1041 1039 1042 if (uncheckedResultKeys.size()) { 1040 throw VMTypeError(globalObject, scope, "Proxy handler's 'ownKeys' method returned a key that was not present in its non-extensible target"_s);1043 throwTypeError(globalObject, scope, "Proxy handler's 'ownKeys' method returned a key that was not present in its non-extensible target"_s); 1041 1044 return; 1042 1045 } … … 1111 1114 JSValue handlerValue = this->handler(); 1112 1115 if (handlerValue.isNull()) { 1113 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);1116 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 1114 1117 return false; 1115 1118 } … … 1137 1140 if (!trapResultAsBool) { 1138 1141 if (shouldThrowIfCantSet) 1139 throw VMTypeError(globalObject, scope, "Proxy 'setPrototypeOf' returned false indicating it could not set the prototype value. The operation was expected to succeed"_s);1142 throwTypeError(globalObject, scope, "Proxy 'setPrototypeOf' returned false indicating it could not set the prototype value. The operation was expected to succeed"_s); 1140 1143 return false; 1141 1144 } … … 1151 1154 RETURN_IF_EXCEPTION(scope, false); 1152 1155 if (!isSame) { 1153 throw VMTypeError(globalObject, scope, "Proxy 'setPrototypeOf' trap returned true when its target is non-extensible and the new prototype value is not the same as the current prototype value. It should have returned false"_s);1156 throwTypeError(globalObject, scope, "Proxy 'setPrototypeOf' trap returned true when its target is non-extensible and the new prototype value is not the same as the current prototype value. It should have returned false"_s); 1154 1157 return false; 1155 1158 } … … 1176 1179 JSValue handlerValue = this->handler(); 1177 1180 if (handlerValue.isNull()) { 1178 throw VMTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage);1181 throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); 1179 1182 return { }; 1180 1183 } … … 1197 1200 1198 1201 if (!trapResult.isObject() && !trapResult.isNull()) { 1199 throw VMTypeError(globalObject, scope, "Proxy handler's 'getPrototypeOf' trap should either return an object or null"_s);1202 throwTypeError(globalObject, scope, "Proxy handler's 'getPrototypeOf' trap should either return an object or null"_s); 1200 1203 return { }; 1201 1204 } … … 1211 1214 RETURN_IF_EXCEPTION(scope, { }); 1212 1215 if (!isSame) { 1213 throw VMTypeError(globalObject, scope, "Proxy's 'getPrototypeOf' trap for a non-extensible target should return the same value as the target's prototype"_s);1216 throwTypeError(globalObject, scope, "Proxy's 'getPrototypeOf' trap for a non-extensible target should return the same value as the target's prototype"_s); 1214 1217 return { }; 1215 1218 }
Note:
See TracChangeset
for help on using the changeset viewer.