Diff
Modified: trunk/Source/_javascript_Core/API/JSCallbackObject.h (148161 => 148162)
--- trunk/Source/_javascript_Core/API/JSCallbackObject.h 2013-04-11 01:22:52 UTC (rev 148161)
+++ trunk/Source/_javascript_Core/API/JSCallbackObject.h 2013-04-11 01:25:33 UTC (rev 148162)
@@ -181,6 +181,7 @@
static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&);
static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
+ static void putByIndex(JSCell*, ExecState*, unsigned, JSValue, bool shouldThrow);
static bool deleteProperty(JSCell*, ExecState*, PropertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned);
Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (148161 => 148162)
--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h 2013-04-11 01:22:52 UTC (rev 148161)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h 2013-04-11 01:25:33 UTC (rev 148162)
@@ -294,6 +294,65 @@
}
template <class Parent>
+void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyIndex, JSValue value, bool shouldThrow)
+{
+ JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
+ JSContextRef ctx = toRef(exec);
+ JSObjectRef thisRef = toRef(thisObject);
+ RefPtr<OpaqueJSString> propertyNameRef;
+ JSValueRef valueRef = toRef(exec, value);
+ Identifier propertyName = Identifier(exec, String::number(propertyIndex));
+
+ for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
+ if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
+ if (!propertyNameRef)
+ propertyNameRef = OpaqueJSString::create(propertyName.impl());
+ JSValueRef exception = 0;
+ bool result;
+ {
+ APICallbackShim callbackShim(exec);
+ result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
+ }
+ if (exception)
+ throwError(exec, toJS(exec, exception));
+ if (result || exception)
+ return;
+ }
+
+ if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
+ if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
+ if (entry->attributes & kJSPropertyAttributeReadOnly)
+ return;
+ if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
+ if (!propertyNameRef)
+ propertyNameRef = OpaqueJSString::create(propertyName.impl());
+ JSValueRef exception = 0;
+ bool result;
+ {
+ APICallbackShim callbackShim(exec);
+ result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
+ }
+ if (exception)
+ throwError(exec, toJS(exec, exception));
+ if (result || exception)
+ return;
+ }
+ }
+ }
+
+ if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
+ if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
+ if (entry->attributes & kJSPropertyAttributeReadOnly)
+ return;
+ break;
+ }
+ }
+ }
+
+ return Parent::putByIndex(thisObject, exec, propertyIndex, value, shouldThrow);
+}
+
+template <class Parent>
bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (148161 => 148162)
--- trunk/Source/_javascript_Core/API/tests/testapi.c 2013-04-11 01:22:52 UTC (rev 148161)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c 2013-04-11 01:25:33 UTC (rev 148162)
@@ -491,6 +491,11 @@
return true;
}
+ if (JSStringIsEqualToUTF8CString(propertyName, "make_throw") || JSStringIsEqualToUTF8CString(propertyName, "0")) {
+ *exception = JSValueMakeNumber(context, 5);
+ return true;
+ }
+
return false;
}
Modified: trunk/Source/_javascript_Core/API/tests/testapi.js (148161 => 148162)
--- trunk/Source/_javascript_Core/API/tests/testapi.js 2013-04-11 01:22:52 UTC (rev 148161)
+++ trunk/Source/_javascript_Core/API/tests/testapi.js 2013-04-11 01:25:33 UTC (rev 148162)
@@ -262,6 +262,10 @@
for (var i = 0; i < 6; ++i)
var x = PropertyCatchalls.x;
shouldBe("x", null);
+var make_throw = 'make_throw';
+shouldThrow("PropertyCatchalls[make_throw]=1");
+make_throw = 0;
+shouldThrow("PropertyCatchalls[make_throw]=1");
for (var i = 0; i < 10; ++i) {
for (var p in PropertyCatchalls) {
Modified: trunk/Source/_javascript_Core/ChangeLog (148161 => 148162)
--- trunk/Source/_javascript_Core/ChangeLog 2013-04-11 01:22:52 UTC (rev 148161)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-04-11 01:25:33 UTC (rev 148162)
@@ -1,3 +1,22 @@
+2013-04-10 Oliver Hunt <[email protected]>
+
+ Set trap is not being called for API objects
+ https://bugs.webkit.org/show_bug.cgi?id=114403
+
+ Reviewed by Anders Carlsson.
+
+ Intercept putByIndex on the callback object and add tests
+ to make sure we don't regress in future.
+
+ * API/JSCallbackObject.h:
+ (JSCallbackObject):
+ * API/JSCallbackObjectFunctions.h:
+ (JSC::::putByIndex):
+ (JSC):
+ * API/tests/testapi.c:
+ (PropertyCatchalls_setProperty):
+ * API/tests/testapi.js:
+
2013-04-10 Benjamin Poulain <[email protected]>
Mass remove all the empty directories