Changeset 19234 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 29, 2007, 1:58:31 PM (18 years ago)
Author:
kmccullo
Message:

JavaScriptCore:

Reviewed by Geoff and Oliver.

  • rdar://problem/4955561
  • missusing JavaScript shouldn't crash webkit. Now it doesn't, in this case.
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::callAsFunction):
  • bindings/runtime_method.cpp: (RuntimeMethod::callAsFunction):
  • bindings/runtime_object.cpp: (RuntimeObjectImp::callAsFunction):

LayoutTests:

Reviewed by Geoff and Oliver.

  • rdar://problem/4955561
  • missusing JavaScript shouldn't crash webkit. Now it doesn't in this case.
  • plugins/call-as-function-test-expected.txt: Added.
  • plugins/call-as-function-test.html: Added.
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r19209 r19234  
     12007-01-29  Kevin McCullough  <[email protected]>
     2
     3        Reviewed by Geoff and Oliver.
     4
     5        - rdar://problem/4955561
     6        - missusing JavaScript shouldn't crash webkit.  Now it doesn't, in this case.
     7
     8        * bindings/objc/objc_runtime.mm:
     9        (ObjcFallbackObjectImp::callAsFunction):
     10        * bindings/runtime_method.cpp:
     11        (RuntimeMethod::callAsFunction):
     12        * bindings/runtime_object.cpp:
     13        (RuntimeObjectImp::callAsFunction):
     14
    1152007-01-28  Geoffrey Garen  <[email protected]>
    216
  • trunk/JavaScriptCore/bindings/objc/objc_runtime.mm

    r19183 r19234  
    277277JSValue* ObjcFallbackObjectImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
    278278{
     279    if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info)
     280        return throwError(exec, TypeError);
     281
    279282    JSValue* result = jsUndefined();
    280    
     283
    281284    RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(thisObj);
    282     if (imp) {
    283         Instance* instance = imp->getInternalInstance();
    284        
    285         instance->begin();
    286 
    287         ObjcInstance* objcInstance = static_cast<ObjcInstance*>(instance);
    288         id targetObject = objcInstance->getObject();
    289        
    290         if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]){
    291             MethodList methodList;
    292             ObjcClass* objcClass = static_cast<ObjcClass*>(instance->getClass());
    293             ObjcMethod* fallbackMethod = new ObjcMethod (objcClass->isa(), sel_getName(@selector(invokeUndefinedMethodFromWebScript:withArguments:)));
    294             fallbackMethod->setJavaScriptName((CFStringRef)[NSString stringWithCString:_item.ascii() encoding:NSASCIIStringEncoding]);
    295             methodList.addMethod ((Method*)fallbackMethod);
    296             result = instance->invokeMethod(exec, methodList, args);
    297             delete fallbackMethod;
    298         }
    299                
    300         instance->end();
    301     }
     285    Instance* instance = imp->getInternalInstance();
     286
     287    instance->begin();
     288
     289    ObjcInstance* objcInstance = static_cast<ObjcInstance*>(instance);
     290    id targetObject = objcInstance->getObject();
     291   
     292    if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]){
     293        MethodList methodList;
     294        ObjcClass* objcClass = static_cast<ObjcClass*>(instance->getClass());
     295        ObjcMethod* fallbackMethod = new ObjcMethod (objcClass->isa(), sel_getName(@selector(invokeUndefinedMethodFromWebScript:withArguments:)));
     296        fallbackMethod->setJavaScriptName((CFStringRef)[NSString stringWithCString:_item.ascii() encoding:NSASCIIStringEncoding]);
     297        methodList.addMethod ((Method*)fallbackMethod);
     298        result = instance->invokeMethod(exec, methodList, args);
     299        delete fallbackMethod;
     300    }
     301           
     302    instance->end();
    302303
    303304    return result;
  • trunk/JavaScriptCore/bindings/runtime_method.cpp

    r15698 r19234  
    7070{
    7171    if (_methodList.length() > 0) {
    72         RuntimeObjectImp *imp;
    73        
    74         // If thisObj is the DOM object for a plugin, get the corresponding
    75         // runtime object from the DOM object.
    76         if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) {
    77             JSValue *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
    78             imp = static_cast<RuntimeObjectImp*>(runtimeObject);
     72        RuntimeObjectImp *imp = 0;
     73
     74        if (thisObj->classInfo() == &KJS::RuntimeObjectImp::info) {
     75            imp = static_cast<RuntimeObjectImp*>(thisObj);
     76        } else {
     77            // If thisObj is the DOM object for a plugin, get the corresponding
     78            // runtime object from the DOM object.
     79            JSValue* value = thisObj->get(exec, "__apple_runtime_object");
     80            if (value->isObject(&KJS::RuntimeObjectImp::info))   
     81                imp = static_cast<RuntimeObjectImp*>(value);
    7982        }
    80         else {
    81             imp = static_cast<RuntimeObjectImp*>(thisObj);
    82         }
    83         if (imp) {
    84             Instance *instance = imp->getInternalInstance();
    85            
    86             instance->begin();
    87            
    88             JSValue *aValue = instance->invokeMethod(exec, _methodList, args);
    89            
    90             instance->end();
    91            
    92             return aValue;
    93         }
     83
     84        if (!imp)
     85            return throwError(exec, TypeError);
     86
     87        Instance *instance = imp->getInternalInstance();
     88        instance->begin();
     89        JSValue *aValue = instance->invokeMethod(exec, _methodList, args);
     90        instance->end();
     91        return aValue;
    9492    }
    95    
     93
    9694    return jsUndefined();
    9795}
  • trunk/JavaScriptCore/bindings/runtime_object.cpp

    r15969 r19234  
    188188    instance->begin();
    189189
    190     JSValue *aValue = getInternalInstance()->invokeDefaultMethod(exec, args);
     190    JSValue *aValue = instance->invokeDefaultMethod(exec, args);
    191191   
    192192    instance->end();
Note: See TracChangeset for help on using the changeset viewer.