Changeset 96243 in webkit
- Timestamp:
- Sep 28, 2011 12:02:57 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r96238 r96243 1 2011-09-28 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=64679 4 Fix bugs in Array.prototype this handling. 5 6 Reviewed by Oliver Hunt. 7 8 * runtime/ArrayPrototype.cpp: 9 (JSC::arrayProtoFuncJoin): 10 (JSC::arrayProtoFuncConcat): 11 (JSC::arrayProtoFuncPop): 12 (JSC::arrayProtoFuncPush): 13 (JSC::arrayProtoFuncReverse): 14 (JSC::arrayProtoFuncShift): 15 (JSC::arrayProtoFuncSlice): 16 (JSC::arrayProtoFuncSort): 17 (JSC::arrayProtoFuncSplice): 18 (JSC::arrayProtoFuncUnShift): 19 (JSC::arrayProtoFuncFilter): 20 (JSC::arrayProtoFuncMap): 21 (JSC::arrayProtoFuncEvery): 22 (JSC::arrayProtoFuncForEach): 23 (JSC::arrayProtoFuncSome): 24 (JSC::arrayProtoFuncReduce): 25 (JSC::arrayProtoFuncReduceRight): 26 (JSC::arrayProtoFuncIndexOf): 27 (JSC::arrayProtoFuncLastIndexOf): 28 - These methods should throw if this value is undefined. 29 1 30 2011-09-27 Yuqiang Xian <yuqiang.xian@intel.com> 2 31 -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r95936 r96243 272 272 EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec) 273 273 { 274 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);274 JSObject* thisObj = exec->hostThisValue().toObject(exec); 275 275 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 276 276 if (exec->hadException()) … … 342 342 JSArray* arr = constructEmptyArray(exec); 343 343 unsigned n = 0; 344 JSValue curArg = thisValue.toThisObject(exec); 344 JSValue curArg = thisValue.toObject(exec); 345 if (exec->hadException()) 346 return JSValue::encode(jsUndefined()); 345 347 size_t i = 0; 346 348 size_t argCount = exec->argumentCount(); … … 374 376 return JSValue::encode(asArray(thisValue)->pop()); 375 377 376 JSObject* thisObj = thisValue.to ThisObject(exec);378 JSObject* thisObj = thisValue.toObject(exec); 377 379 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 378 380 if (exec->hadException()) … … 401 403 } 402 404 403 JSObject* thisObj = thisValue.to ThisObject(exec);405 JSObject* thisObj = thisValue.toObject(exec); 404 406 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 405 407 if (exec->hadException()) … … 423 425 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec) 424 426 { 425 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);427 JSObject* thisObj = exec->hostThisValue().toObject(exec); 426 428 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 427 429 if (exec->hadException()) … … 449 451 EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec) 450 452 { 451 JSObject* thisObj = exec->hostThisValue().toThisObject(exec); 453 JSObject* thisObj = exec->hostThisValue().toObject(exec); 454 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 455 if (exec->hadException()) 456 return JSValue::encode(jsUndefined()); 457 452 458 JSValue result; 453 454 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);455 if (exec->hadException())456 return JSValue::encode(jsUndefined());457 458 459 if (length == 0) { 459 460 putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(length)); … … 480 481 { 481 482 // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10 482 JSObject* thisObj = exec->hostThisValue().toThisObject(exec); 483 JSObject* thisObj = exec->hostThisValue().toObject(exec); 484 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 485 if (exec->hadException()) 486 return JSValue::encode(jsUndefined()); 483 487 484 488 // We return a new array 485 489 JSArray* resObj = constructEmptyArray(exec); 486 490 JSValue result = resObj; 487 488 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);489 if (exec->hadException())490 return JSValue::encode(jsUndefined());491 491 492 492 unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, length); … … 504 504 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec) 505 505 { 506 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);506 JSObject* thisObj = exec->hostThisValue().toObject(exec); 507 507 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 508 508 if (!length || exec->hadException()) … … 566 566 // 15.4.4.12 567 567 568 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);568 JSObject* thisObj = exec->hostThisValue().toObject(exec); 569 569 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 570 570 if (exec->hadException()) … … 634 634 // 15.4.4.13 635 635 636 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);636 JSObject* thisObj = exec->hostThisValue().toObject(exec); 637 637 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 638 638 if (exec->hadException()) … … 661 661 EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec) 662 662 { 663 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);663 JSObject* thisObj = exec->hostThisValue().toObject(exec); 664 664 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 665 665 if (exec->hadException()) … … 720 720 EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec) 721 721 { 722 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);722 JSObject* thisObj = exec->hostThisValue().toObject(exec); 723 723 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 724 724 if (exec->hadException()) … … 782 782 EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec) 783 783 { 784 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);784 JSObject* thisObj = exec->hostThisValue().toObject(exec); 785 785 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 786 786 if (exec->hadException()) … … 840 840 EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec) 841 841 { 842 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);842 JSObject* thisObj = exec->hostThisValue().toObject(exec); 843 843 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 844 844 if (exec->hadException()) … … 890 890 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec) 891 891 { 892 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);892 JSObject* thisObj = exec->hostThisValue().toObject(exec); 893 893 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 894 894 if (exec->hadException()) … … 947 947 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec) 948 948 { 949 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);949 JSObject* thisObj = exec->hostThisValue().toObject(exec); 950 950 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 951 951 if (exec->hadException()) … … 1022 1022 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec) 1023 1023 { 1024 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);1024 JSObject* thisObj = exec->hostThisValue().toObject(exec); 1025 1025 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 1026 1026 if (exec->hadException()) … … 1097 1097 { 1098 1098 // 15.4.4.14 1099 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);1099 JSObject* thisObj = exec->hostThisValue().toObject(exec); 1100 1100 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 1101 1101 if (exec->hadException()) … … 1118 1118 { 1119 1119 // 15.4.4.15 1120 JSObject* thisObj = exec->hostThisValue().to ThisObject(exec);1120 JSObject* thisObj = exec->hostThisValue().toObject(exec); 1121 1121 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 1122 1122 if (!length)
Note: See TracChangeset
for help on using the changeset viewer.