Title: [183754] trunk/Source/_javascript_Core
Revision
183754
Author
saambara...@gmail.com
Date
2015-05-04 11:47:33 -0700 (Mon, 04 May 2015)

Log Message

JSCallbackObject does not maintain symmetry between accesses for getOwnPropertySlot and put
https://bugs.webkit.org/show_bug.cgi?id=144265

Reviewed by Geoffrey Garen.

JSCallbackObject will defer to a parent's implementation of getOwnPropertySlot
for a static function if the parent has that property slot. JSCallbackObject::put
did not maintain this symmetry of also calling ::put on the parent if the parent
has the property. We should ensure that this symmetry exists.

* API/JSCallbackObjectFunctions.h:
(JSC::JSCallbackObject<Parent>::put):
* API/tests/testapi.c:
* API/tests/testapi.js:
(globalStaticFunction2):
(this.globalStaticFunction2):
(iAmNotAStaticFunction):
(this.iAmNotAStaticFunction):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (183753 => 183754)


--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2015-05-04 18:45:40 UTC (rev 183753)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2015-05-04 18:47:33 UTC (rev 183754)
@@ -270,6 +270,9 @@
             
             if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
                 if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
+                    PropertySlot getSlot(thisObject);
+                    if (Parent::getOwnPropertySlot(thisObject, exec, propertyName, getSlot))
+                        return Parent::put(thisObject, exec, propertyName, value, slot);
                     if (entry->attributes & kJSPropertyAttributeReadOnly)
                         return;
                     thisObject->JSCallbackObject<Parent>::putDirect(exec->vm(), propertyName, value); // put as override property

Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (183753 => 183754)


--- trunk/Source/_javascript_Core/API/tests/testapi.c	2015-05-04 18:45:40 UTC (rev 183753)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c	2015-05-04 18:47:33 UTC (rev 183754)
@@ -960,6 +960,7 @@
 
 static JSStaticFunction globalObject_staticFunctions[] = {
     { "globalStaticFunction", globalObject_call, kJSPropertyAttributeNone },
+    { "globalStaticFunction2", globalObject_call, kJSPropertyAttributeNone },
     { "gc", functionGC, kJSPropertyAttributeNone },
     { 0, 0, 0 }
 };

Modified: trunk/Source/_javascript_Core/API/tests/testapi.js (183753 => 183754)


--- trunk/Source/_javascript_Core/API/tests/testapi.js	2015-05-04 18:45:40 UTC (rev 183753)
+++ trunk/Source/_javascript_Core/API/tests/testapi.js	2015-05-04 18:47:33 UTC (rev 183754)
@@ -74,7 +74,21 @@
 
 shouldBe("globalStaticValue", 3);
 shouldBe("globalStaticFunction()", 4);
+shouldBe("this.globalStaticFunction()", 4);
 
+function globalStaticFunction2() {
+    return 10;
+}
+shouldBe("globalStaticFunction2();", 10);
+this.globalStaticFunction2 = function() { return 20; }
+shouldBe("globalStaticFunction2();", 20);
+shouldBe("this.globalStaticFunction2();", 20);
+
+function iAmNotAStaticFunction() { return 10; }
+shouldBe("iAmNotAStaticFunction();", 10);
+this.iAmNotAStaticFunction = function() { return 20; }
+shouldBe("iAmNotAStaticFunction();", 20);
+
 shouldBe("typeof MyObject", "function"); // our object implements 'call'
 MyObject.cantFind = 1;
 shouldBe("MyObject.cantFind", undefined);

Modified: trunk/Source/_javascript_Core/ChangeLog (183753 => 183754)


--- trunk/Source/_javascript_Core/ChangeLog	2015-05-04 18:45:40 UTC (rev 183753)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-05-04 18:47:33 UTC (rev 183754)
@@ -1,3 +1,24 @@
+2015-05-04  Saam Barati  <saambara...@gmail.com>
+
+        JSCallbackObject does not maintain symmetry between accesses for getOwnPropertySlot and put
+        https://bugs.webkit.org/show_bug.cgi?id=144265
+
+        Reviewed by Geoffrey Garen.
+
+        JSCallbackObject will defer to a parent's implementation of getOwnPropertySlot
+        for a static function if the parent has that property slot. JSCallbackObject::put 
+        did not maintain this symmetry of also calling ::put on the parent if the parent 
+        has the property. We should ensure that this symmetry exists.
+
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::JSCallbackObject<Parent>::put):
+        * API/tests/testapi.c:
+        * API/tests/testapi.js:
+        (globalStaticFunction2):
+        (this.globalStaticFunction2):
+        (iAmNotAStaticFunction):
+        (this.iAmNotAStaticFunction):
+
 2015-05-04  Andreas Kling  <akl...@apple.com>
 
         Make ExecState::vm() branchless in release builds.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to