Skip to content
  • mhahnenberg@apple.com's avatar
    ObjCCallbackFunctionImpl shouldn't store a JSContext · e4b8bb7e
    mhahnenberg@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=122531
    
    Reviewed by Geoffrey Garen.
    
    The m_context field in ObjCCallbackFunctionImpl is vestigial and is only incidentally correct
    in the common case. It's also no longer necessary in that we can look up the current JSContext
    by looking using the globalObject of the callee when the function callback is invoked.
    
    Also added a new test that would cause us to crash previously. The test required making
    JSContextGetGlobalContext public API so that clients can obtain a JSContext from the JSContextRef
    in C API callbacks.
    
    * API/JSContextRef.h:
    * API/JSContextRefPrivate.h:
    * API/ObjCCallbackFunction.mm:
    (JSC::ObjCCallbackFunctionImpl::ObjCCallbackFunctionImpl):
    (JSC::objCCallbackFunctionCallAsFunction):
    (objCCallbackFunctionForInvocation):
    * API/WebKitAvailability.h:
    * API/tests/CurrentThisInsideBlockGetterTest.h: Added.
    * API/tests/CurrentThisInsideBlockGetterTest.mm: Added.
    (CallAsConstructor):
    (ConstructorFinalize):
    (ConstructorClass):
    (+[JSValue valueWithConstructorDescriptor:inContext:]):
    (-[JSContext valueWithConstructorDescriptor:]):
    (currentThisInsideBlockGetterTest):
    * API/tests/testapi.mm:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * debugger/Debugger.cpp: Had to add some fully qualified names to avoid conflicts with Mac OS X headers.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    e4b8bb7e