Changeset 31267 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Mar 24, 2008, 7:26:24 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-03-23 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Fix http://bugs.webkit.org/show_bug.cgi?id=18048
The "thisObject" parameter to JSEvaluateScript is not used properly

Making passing a thisObject to JSEvaluateScript actually set the thisObject of the created
ExecState.

  • API/testapi.c: (main): Add tests for setting the thisObject when calling JSEvaluateScript.
  • kjs/ExecState.cpp: (KJS::ExecState::ExecState): Assign the thisObject to m_thisValue and remove the comment.

WebCore:

2008-03-24 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Fix http://bugs.webkit.org/show_bug.cgi?id=18048
The "thisObject" parameter to JSEvaluateScript is not used properly

  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::evaluate): No need to pass a thisObject since we want the global object to be used.
  • bridge/jni/jni_jsobject.mm: (JavaJSObject::eval): To avoid any change to this function, don't pass a thisObject to keep the same behavior.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/testapi.c

    r30795 r31267  
    870870    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
    871871    ASSERT(JSValueIsEqual(context, v, o, NULL));
    872    
     872
     873    functionBody = JSStringCreateWithUTF8CString("return eval(\"this\");");
     874    function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, NULL);
     875    JSStringRelease(functionBody);
     876    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
     877    ASSERT(JSValueIsEqual(context, v, globalObject, NULL));
     878    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
     879    ASSERT(JSValueIsEqual(context, v, o, NULL));
     880
     881    JSStringRef script = JSStringCreateWithUTF8CString("this;");
     882    v = JSEvaluateScript(context, script, NULL, NULL, 0, NULL);
     883    ASSERT(JSValueIsEqual(context, v, globalObject, NULL));
     884    v = JSEvaluateScript(context, script, o, NULL, 0, NULL);
     885    ASSERT(JSValueIsEqual(context, v, o, NULL));
     886    JSStringRelease(script);
     887
     888    script = JSStringCreateWithUTF8CString("eval(this);");
     889    v = JSEvaluateScript(context, script, NULL, NULL, 0, NULL);
     890    ASSERT(JSValueIsEqual(context, v, globalObject, NULL));
     891    v = JSEvaluateScript(context, script, o, NULL, 0, NULL);
     892    ASSERT(JSValueIsEqual(context, v, o, NULL));
     893    JSStringRelease(script);
     894
    873895    char* scriptUTF8 = createStringWithContentsOfFile(scriptPath);
    874896    if (!scriptUTF8)
    875897        printf("FAIL: Test script could not be loaded.\n");
    876898    else {
    877         JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
     899        script = JSStringCreateWithUTF8CString(scriptUTF8);
    878900        result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception);
    879901        if (JSValueIsUndefined(context, result))
Note: See TracChangeset for help on using the changeset viewer.