Changeset 148162 in webkit
- Timestamp:
- Apr 10, 2013 6:25:33 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackObject.h
r145119 r148162 182 182 183 183 static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&); 184 static void putByIndex(JSCell*, ExecState*, unsigned, JSValue, bool shouldThrow); 184 185 185 186 static bool deleteProperty(JSCell*, ExecState*, PropertyName); -
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r147349 r148162 295 295 296 296 template <class Parent> 297 void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyIndex, JSValue value, bool shouldThrow) 298 { 299 JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell); 300 JSContextRef ctx = toRef(exec); 301 JSObjectRef thisRef = toRef(thisObject); 302 RefPtr<OpaqueJSString> propertyNameRef; 303 JSValueRef valueRef = toRef(exec, value); 304 Identifier propertyName = Identifier(exec, String::number(propertyIndex)); 305 306 for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { 307 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { 308 if (!propertyNameRef) 309 propertyNameRef = OpaqueJSString::create(propertyName.impl()); 310 JSValueRef exception = 0; 311 bool result; 312 { 313 APICallbackShim callbackShim(exec); 314 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); 315 } 316 if (exception) 317 throwError(exec, toJS(exec, exception)); 318 if (result || exception) 319 return; 320 } 321 322 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { 323 if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) { 324 if (entry->attributes & kJSPropertyAttributeReadOnly) 325 return; 326 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { 327 if (!propertyNameRef) 328 propertyNameRef = OpaqueJSString::create(propertyName.impl()); 329 JSValueRef exception = 0; 330 bool result; 331 { 332 APICallbackShim callbackShim(exec); 333 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); 334 } 335 if (exception) 336 throwError(exec, toJS(exec, exception)); 337 if (result || exception) 338 return; 339 } 340 } 341 } 342 343 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { 344 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) { 345 if (entry->attributes & kJSPropertyAttributeReadOnly) 346 return; 347 break; 348 } 349 } 350 } 351 352 return Parent::putByIndex(thisObject, exec, propertyIndex, value, shouldThrow); 353 } 354 355 template <class Parent> 297 356 bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) 298 357 { -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r146711 r148162 492 492 } 493 493 494 if (JSStringIsEqualToUTF8CString(propertyName, "make_throw") || JSStringIsEqualToUTF8CString(propertyName, "0")) { 495 *exception = JSValueMakeNumber(context, 5); 496 return true; 497 } 498 494 499 return false; 495 500 } -
trunk/Source/JavaScriptCore/API/tests/testapi.js
r113660 r148162 263 263 var x = PropertyCatchalls.x; 264 264 shouldBe("x", null); 265 var make_throw = 'make_throw'; 266 shouldThrow("PropertyCatchalls[make_throw]=1"); 267 make_throw = 0; 268 shouldThrow("PropertyCatchalls[make_throw]=1"); 265 269 266 270 for (var i = 0; i < 10; ++i) { -
trunk/Source/JavaScriptCore/ChangeLog
r148159 r148162 1 2013-04-10 Oliver Hunt <oliver@apple.com> 2 3 Set trap is not being called for API objects 4 https://bugs.webkit.org/show_bug.cgi?id=114403 5 6 Reviewed by Anders Carlsson. 7 8 Intercept putByIndex on the callback object and add tests 9 to make sure we don't regress in future. 10 11 * API/JSCallbackObject.h: 12 (JSCallbackObject): 13 * API/JSCallbackObjectFunctions.h: 14 (JSC::::putByIndex): 15 (JSC): 16 * API/tests/testapi.c: 17 (PropertyCatchalls_setProperty): 18 * API/tests/testapi.js: 19 1 20 2013-04-10 Benjamin Poulain <bpoulain@apple.com> 2 21
Note: See TracChangeset
for help on using the changeset viewer.