Changeset 15149 in webkit for trunk/JavaScriptCore/API/minidom.c


Ignore:
Timestamp:
Jul 3, 2006, 7:35:09 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Darin.


  • Refined value conversions in the API:
    • failed toNumber returns NaN
    • failed toObject returns NULL
    • failed toString returns empty string


  • Refined excpetion handling in the API:
    • failed value conversions do not throw exceptions
    • uncaught exceptions in JSEvaluate, JSObjectCallAsFunction, and JSObjectCallAsConstructor are returned through a JSValueRef* exception argument
    • removed JSContextHasException, because JSContextGetException does the same job


  • API/JSBase.h:
  • API/JSCharBufferRef.cpp: (JSValueCopyStringValue):
  • API/JSContextRef.cpp: (JSEvaluate):
  • API/JSContextRef.h:
  • API/JSNodeList.c: Added test code demonstrating how you would use toNumber, and why you probably don't need toUInt32, etc. (JSNodeListPrototype_item): (JSNodeList_getProperty):
  • API/JSObjectRef.cpp: (JSValueToObject): (JSObjectCallAsFunction): (JSObjectCallAsConstructor):
  • API/JSObjectRef.h:
  • API/JSValueRef.cpp: (JSValueToNumber):
  • API/JSValueRef.h:
  • API/minidom.c: (main):
  • API/testapi.c: (main): Added tests for new rules, and call to JSGCProtect to fix Intel crash
  • JavaScriptCore.exp:
File:
1 edited

Legend:

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

    r15133 r15149  
    5050    char* script = createStringWithContentsOfFile("minidom.js");
    5151    JSCharBufferRef scriptBuf = JSCharBufferCreateUTF8(script);
    52     JSValueRef result;
    53     JSEvaluate(context, globalObject, scriptBuf, NULL, 0, &result);
    54 
    55     if (JSValueIsUndefined(result))
     52    JSValueRef exception;
     53    JSValueRef result = JSEvaluate(context, scriptBuf, NULL, NULL, 0, &exception);
     54    if (result)
    5655        printf("PASS: Test script executed successfully.\n");
    5756    else {
    58         printf("FAIL: Test script returned unexcpected value:\n");
    59         JSCharBufferRef resultBuf = JSValueCopyStringValue(context, result);
    60         CFStringRef resultCF = CFStringCreateWithJSCharBuffer(kCFAllocatorDefault, resultBuf);
    61         CFShow(resultCF);
    62         CFRelease(resultCF);
    63         JSCharBufferRelease(resultBuf);
     57        printf("FAIL: Test script threw exception:\n");
     58        JSCharBufferRef exceptionBuf = JSValueCopyStringValue(context, exception);
     59        CFStringRef exceptionCF = CFStringCreateWithJSCharBuffer(kCFAllocatorDefault, exceptionBuf);
     60        CFShow(exceptionCF);
     61        CFRelease(exceptionCF);
     62        JSCharBufferRelease(exceptionBuf);
    6463    }
    6564    JSCharBufferRelease(scriptBuf);
Note: See TracChangeset for help on using the changeset viewer.