Changeset 51068 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Nov 17, 2009, 12:41:10 AM (16 years ago)
Author:
[email protected]
Message:

Incorrect use of JavaScriptCore API in DumpRenderTree
https://bugs.webkit.org/show_bug.cgi?id=31577

Reviewed by Maciej Stachowiak

Return undefined rather than a literal null.

Location:
trunk/JavaScriptCore/API
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/APICast.h

    r50964 r51068  
    5252inline JSC::ExecState* toJS(JSContextRef c)
    5353{
     54    ASSERT(c);
    5455    return reinterpret_cast<JSC::ExecState*>(const_cast<OpaqueJSContext*>(c));
    5556}
     
    5758inline JSC::ExecState* toJS(JSGlobalContextRef c)
    5859{
     60    ASSERT(c);
    5961    return reinterpret_cast<JSC::ExecState*>(c);
    6062}
    6163
    62 inline JSC::JSValue toJS(JSC::ExecState*, JSValueRef v)
     64inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
    6365{
     66    ASSERT_UNUSED(exec, exec);
     67    ASSERT(v);
    6468#if USE(JSVALUE32_64)
    6569    JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
     
    7478}
    7579
    76 inline JSC::JSValue toJSForGC(JSC::ExecState*, JSValueRef v)
     80inline JSC::JSValue toJSForGC(JSC::ExecState* exec, JSValueRef v)
    7781{
     82    ASSERT_UNUSED(exec, exec);
     83    ASSERT(v);
    7884#if USE(JSVALUE32_64)
    7985    JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r48836 r51068  
    132132                value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    133133            }
    134             exec->setException(toJS(exec, exception));
     134            if (exception) {
     135                exec->setException(toJS(exec, exception));
     136                slot.setValue(jsUndefined());
     137                return true;
     138            }
    135139            if (value) {
    136140                slot.setValue(toJS(exec, value));
    137                 return true;
    138             }
    139             if (exception) {
    140                 slot.setValue(jsUndefined());
    141141                return true;
    142142            }
     
    185185                result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    186186            }
    187             exec->setException(toJS(exec, exception));
     187            if (exception)
     188                exec->setException(toJS(exec, exception));
    188189            if (result || exception)
    189190                return;
     
    203204                        result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    204205                    }
    205                     exec->setException(toJS(exec, exception));
     206                    if (exception)
     207                        exec->setException(toJS(exec, exception));
    206208                    if (result || exception)
    207209                        return;
     
    241243                result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    242244            }
    243             exec->setException(toJS(exec, exception));
     245            if (exception)
     246                exec->setException(toJS(exec, exception));
    244247            if (result || exception)
    245248                return true;
     
    302305                result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
    303306            }
    304             exec->setException(toJS(exec, exception));
     307            if (exception)
     308                exec->setException(toJS(exec, exception));
    305309            return result;
    306310        }
     
    326330                result = hasInstance(execRef, thisRef, valueRef, &exception);
    327331            }
    328             exec->setException(toJS(exec, exception));
     332            if (exception)
     333                exec->setException(toJS(exec, exception));
    329334            return result;
    330335        }
     
    364369                result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
    365370            }
    366             exec->setException(toJS(exec, exception));
     371            if (exception)
     372                exec->setException(toJS(exec, exception));
    367373            return result;
    368374        }
     
    436442
    437443            double dValue;
    438             return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
     444            if (value)
     445                return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
    439446        }
    440447           
     
    460467                return "";
    461468            }
    462             return toJS(exec, value).getString();
     469            if (value)
     470                return toJS(exec, value).getString();
    463471        }
    464472           
     
    508516                        value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    509517                    }
    510                     exec->setException(toJS(exec, exception));
     518                    if (exception) {
     519                        exec->setException(toJS(exec, exception));
     520                        return jsUndefined();
     521                    }
    511522                    if (value)
    512523                        return toJS(exec, value);
    513                     if (exception)
    514                         return jsUndefined();
    515524                }
    516                    
     525
    517526    return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback.");
    518527}
     
    561570                value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    562571            }
    563             exec->setException(toJS(exec, exception));
     572            if (exception) {
     573                exec->setException(toJS(exec, exception));
     574                return jsUndefined();
     575            }
    564576            if (value)
    565577                return toJS(exec, value);
    566             if (exception)
    567                 return jsUndefined();
    568578        }
    569579           
  • trunk/JavaScriptCore/API/tests/testapi.c

    r50964 r51068  
    167167        return JSValueMakeUndefined(context);
    168168    }
     169   
     170    if (JSStringIsEqualToUTF8CString(propertyName, "hasPropertyLie")) {
     171        return 0;
     172    }
    169173
    170174    if (JSStringIsEqualToUTF8CString(propertyName, "throwOnGet")) {
     
    177181    }
    178182   
    179     return NULL;
     183    return JSValueMakeNull(context);
    180184}
    181185
     
    300304
    301305    // string conversion -- forward to default object class
    302     return NULL;
     306    return JSValueMakeNull(context);
    303307}
    304308
     
    375379        break;
    376380    default:
    377         return NULL;
     381        return JSValueMakeNull(context);
    378382        break;
    379383    }
     
    383387    JSObjectRef function = JSValueToObject(context, func, exception);
    384388    if (!function)
    385         return NULL;
     389        return JSValueMakeNull(context);
    386390    JSValueRef value = JSObjectCallAsFunction(context, function, object, 0, NULL, exception);
    387391    if (!value) {
Note: See TracChangeset for help on using the changeset viewer.