Changeset 183754 in webkit


Ignore:
Timestamp:
May 4, 2015 11:47:33 AM (9 years ago)
Author:
saambarati1@gmail.com
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):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r183005 r183754  
    271271            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    272272                if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
     273                    PropertySlot getSlot(thisObject);
     274                    if (Parent::getOwnPropertySlot(thisObject, exec, propertyName, getSlot))
     275                        return Parent::put(thisObject, exec, propertyName, value, slot);
    273276                    if (entry->attributes & kJSPropertyAttributeReadOnly)
    274277                        return;
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r182297 r183754  
    961961static JSStaticFunction globalObject_staticFunctions[] = {
    962962    { "globalStaticFunction", globalObject_call, kJSPropertyAttributeNone },
     963    { "globalStaticFunction2", globalObject_call, kJSPropertyAttributeNone },
    963964    { "gc", functionGC, kJSPropertyAttributeNone },
    964965    { 0, 0, 0 }
  • trunk/Source/JavaScriptCore/API/tests/testapi.js

    r165676 r183754  
    7575shouldBe("globalStaticValue", 3);
    7676shouldBe("globalStaticFunction()", 4);
     77shouldBe("this.globalStaticFunction()", 4);
     78
     79function globalStaticFunction2() {
     80    return 10;
     81}
     82shouldBe("globalStaticFunction2();", 10);
     83this.globalStaticFunction2 = function() { return 20; }
     84shouldBe("globalStaticFunction2();", 20);
     85shouldBe("this.globalStaticFunction2();", 20);
     86
     87function iAmNotAStaticFunction() { return 10; }
     88shouldBe("iAmNotAStaticFunction();", 10);
     89this.iAmNotAStaticFunction = function() { return 20; }
     90shouldBe("iAmNotAStaticFunction();", 20);
    7791
    7892shouldBe("typeof MyObject", "function"); // our object implements 'call'
  • trunk/Source/JavaScriptCore/ChangeLog

    r183753 r183754  
     12015-05-04  Saam Barati  <saambarati1@gmail.com>
     2
     3        JSCallbackObject does not maintain symmetry between accesses for getOwnPropertySlot and put
     4        https://bugs.webkit.org/show_bug.cgi?id=144265
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        JSCallbackObject will defer to a parent's implementation of getOwnPropertySlot
     9        for a static function if the parent has that property slot. JSCallbackObject::put
     10        did not maintain this symmetry of also calling ::put on the parent if the parent
     11        has the property. We should ensure that this symmetry exists.
     12
     13        * API/JSCallbackObjectFunctions.h:
     14        (JSC::JSCallbackObject<Parent>::put):
     15        * API/tests/testapi.c:
     16        * API/tests/testapi.js:
     17        (globalStaticFunction2):
     18        (this.globalStaticFunction2):
     19        (iAmNotAStaticFunction):
     20        (this.iAmNotAStaticFunction):
     21
    1222015-05-04  Andreas Kling  <akling@apple.com>
    223
Note: See TracChangeset for help on using the changeset viewer.