Changeset 59118 in webkit


Ignore:
Timestamp:
May 10, 2010 7:06:11 PM (14 years ago)
Author:
dumi@chromium.org
Message:

WebCore: Cleaning up and fixing the existing JSC DB bindings.
https://bugs.webkit.org/show_bug.cgi?id=34994

Reviewed by Brady Eidson.

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::openDatabase):

  • bindings/js/JSDatabaseCustom.cpp:

(WebCore::JSDatabase::changeVersion):
(WebCore::createTransaction):
(WebCore::JSDatabase::transaction):
(WebCore::JSDatabase::readTransaction):

  • bindings/js/JSSQLTransactionCustom.cpp:

(WebCore::JSSQLTransaction::executeSql):

LayoutTests: Fixing the expectations for openDatabase() in cross-frame-access-call.html.
Related to changes in patches #6 and #7 at https://bugs.webkit.org/show_bug.cgi?id=34994.

Reviewed by Brady Eidson.

  • http/tests/security/cross-frame-access-call-expected.txt:
  • http/tests/security/cross-frame-access-call.html:
  • platform/chromium-linux/http/tests/security/cross-frame-access-call-expected.txt: Removed.
  • platform/chromium-mac/http/tests/security/cross-frame-access-call-expected.txt: Removed.
  • platform/chromium-win/http/tests/security/cross-frame-access-call-expected.txt: Removed.
  • platform/chromium/http: Added.
  • platform/chromium/http/tests: Added.
  • platform/chromium/http/tests/security: Added.
  • platform/chromium/http/tests/security/cross-frame-access-call-expected.txt: Copied from LayoutTests/platform/chromium-win/http/tests/security/cross-frame-access-call-expected.txt.
Location:
trunk
Files:
3 added
2 deleted
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r59115 r59118  
     12010-05-10  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Brady Eidson.
     4
     5        Fixing the expectations for openDatabase() in cross-frame-access-call.html.
     6        Related to changes in patches #6 and #7 at https://bugs.webkit.org/show_bug.cgi?id=34994.
     7
     8        * http/tests/security/cross-frame-access-call-expected.txt:
     9        * http/tests/security/cross-frame-access-call.html:
     10        * platform/chromium-linux/http/tests/security/cross-frame-access-call-expected.txt: Removed.
     11        * platform/chromium-mac/http/tests/security/cross-frame-access-call-expected.txt: Removed.
     12        * platform/chromium-win/http/tests/security/cross-frame-access-call-expected.txt: Removed.
     13        * platform/chromium/http: Added.
     14        * platform/chromium/http/tests: Added.
     15        * platform/chromium/http/tests/security: Added.
     16        * platform/chromium/http/tests/security/cross-frame-access-call-expected.txt: Copied from LayoutTests/platform/chromium-win/http/tests/security/cross-frame-access-call-expected.txt.
     17
    1182010-05-10  John Gregg  <johnnyg@google.com>
    219
  • trunk/LayoutTests/http/tests/security/cross-frame-access-call-expected.txt

    r35250 r59118  
    6565PASS: window.getComputedStyle.call(targetWindow, document.body, '') should be 'undefined' and is.
    6666PASS: window.getMatchedCSSRules.call(targetWindow, document.body, '', false) should be 'undefined' and is.
    67 PASS: window.openDatabase.call(targetWindow, 'name') should be 'undefined' and is.
     67PASS: window.openDatabase.call(targetWindow, 'name', '1.0', 'description', 0) should be 'undefined' and is.
    6868PASS: window.atob.call(targetWindow, 'string') should be 'undefined' and is.
    6969PASS: window.btoa.call(targetWindow, 'string') should be 'undefined' and is.
  • trunk/LayoutTests/http/tests/security/cross-frame-access-call.html

    r35250 r59118  
    3535    shouldBe("window.getComputedStyle.call(targetWindow, document.body, '')", "undefined");
    3636    shouldBe("window.getMatchedCSSRules.call(targetWindow, document.body, '', false)", "undefined");
    37     shouldBe("window.openDatabase.call(targetWindow, 'name')", "undefined");
     37    shouldBe("window.openDatabase.call(targetWindow, 'name', '1.0', 'description', 0)", "undefined");
    3838    shouldBe("window.atob.call(targetWindow, 'string')", "undefined");
    3939    shouldBe("window.btoa.call(targetWindow, 'string')", "undefined");
  • trunk/LayoutTests/platform/chromium/http/tests/security/cross-frame-access-call-expected.txt

    r59110 r59118  
    6565PASS: window.getComputedStyle.call(targetWindow, document.body, '') should be 'undefined' and is.
    6666PASS: window.getMatchedCSSRules.call(targetWindow, document.body, '', false) should be 'undefined' and is.
    67 PASS: window.openDatabase.call(targetWindow, 'name') should be 'undefined' and is.
     67PASS: window.openDatabase.call(targetWindow, 'name', '1.0', 'description', 0) should be 'undefined' and is.
    6868PASS: window.atob.call(targetWindow, 'string') should be 'undefined' and is.
    6969PASS: window.btoa.call(targetWindow, 'string') should be 'undefined' and is.
  • trunk/WebCore/ChangeLog

    r59116 r59118  
     12010-05-10  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Brady Eidson.
     4
     5        Cleaning up and fixing the existing JSC DB bindings.
     6        https://bugs.webkit.org/show_bug.cgi?id=34994
     7
     8        * bindings/js/JSDOMWindowCustom.cpp:
     9        (WebCore::JSDOMWindow::openDatabase):
     10        * bindings/js/JSDatabaseCustom.cpp:
     11        (WebCore::JSDatabase::changeVersion):
     12        (WebCore::createTransaction):
     13        (WebCore::JSDatabase::transaction):
     14        (WebCore::JSDatabase::readTransaction):
     15        * bindings/js/JSSQLTransactionCustom.cpp:
     16        (WebCore::JSSQLTransaction::executeSql):
     17
    1182010-05-10  Fumitoshi Ukai  <ukai@chromium.org>
    219
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r58145 r59118  
    968968JSValue JSDOMWindow::openDatabase(ExecState* exec, const ArgList& args)
    969969{
    970     if (!allowsAccessFrom(exec) || (args.size() < 4))
    971         return jsUndefined();
     970    if (!allowsAccessFrom(exec) || (args.size() < 4)) {
     971        setDOMException(exec, SYNTAX_ERR);
     972        return jsUndefined();
     973    }
     974
     975    String name = ustringToString(args.at(0).toString(exec));
     976    if (exec->hadException())
     977        return jsUndefined();
     978
     979    String version = ustringToString(args.at(1).toString(exec));
     980    if (exec->hadException())
     981        return jsUndefined();
     982
     983    String displayName = ustringToString(args.at(2).toString(exec));
     984    if (exec->hadException())
     985        return jsUndefined();
     986
     987    // args.at(3) = estimated size
     988    unsigned long estimatedSize = args.at(3).toUInt32(exec);
     989    if (exec->hadException())
     990        return jsUndefined();
     991
     992    RefPtr<DatabaseCallback> creationCallback;
     993    if (args.size() >= 5) {
     994        if (!args.at(4).isObject()) {
     995            setDOMException(exec, TYPE_MISMATCH_ERR);
     996            return jsUndefined();
     997        }
     998
     999        creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject());
     1000    }
     1001
    9721002    ExceptionCode ec = 0;
    973     const UString& name = args.at(0).toString(exec);
    974     const UString& version = args.at(1).toString(exec);
    975     const UString& displayName = args.at(2).toString(exec);
    976     unsigned long estimatedSize = args.at(3).toInt32(exec);
    977     RefPtr<DatabaseCallback> creationCallback;
    978     if ((args.size() >= 5) && args.at(4).isObject())
    979         creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject());
    980 
    981     JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(ustringToString(name), ustringToString(version), ustringToString(displayName), estimatedSize, creationCallback.release(), ec)));
     1003    JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec)));
    9821004
    9831005    setDOMException(exec, ec);
  • trunk/WebCore/bindings/js/JSDatabaseCustom.cpp

    r58801 r59118  
    5151{
    5252    String oldVersion = ustringToString(args.at(0).toString(exec));
     53    if (exec->hadException())
     54        return jsUndefined();
     55
    5356    String newVersion = ustringToString(args.at(1).toString(exec));
     57    if (exec->hadException())
     58        return jsUndefined();
    5459
    55     JSObject* object;
    56     if (!(object = args.at(2).getObject())) {
     60    JSObject* object = args.at(2).getObject();
     61    if (!object) {
    5762        setDOMException(exec, TYPE_MISMATCH_ERR);
    5863        return jsUndefined();
    5964    }
    60    
    61     RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())));
    62    
     65
     66    RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject())));
     67
    6368    RefPtr<SQLTransactionErrorCallback> errorCallback;
    6469    if (!args.at(3).isNull()) {
    65         if (!(object = args.at(3).getObject())) {
    66             setDOMException(exec, TYPE_MISMATCH_ERR);
    67             return jsUndefined();
    68         }
    69        
    70         errorCallback = JSSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
    71     }
    72    
    73     RefPtr<VoidCallback> successCallback;
    74     if (!args.at(4).isNull()) {
    75         if (!(object = args.at(4).getObject())) {
     70        object = args.at(3).getObject();
     71        if (!object) {
    7672            setDOMException(exec, TYPE_MISMATCH_ERR);
    7773            return jsUndefined();
    7874        }
    7975
    80         successCallback = JSCustomVoidCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
     76        errorCallback = JSSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()));
     77    }
     78
     79    RefPtr<VoidCallback> successCallback;
     80    if (!args.at(4).isNull()) {
     81        object = args.at(4).getObject();
     82        if (!object) {
     83            setDOMException(exec, TYPE_MISMATCH_ERR);
     84            return jsUndefined();
     85        }
     86
     87        successCallback = JSCustomVoidCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()));
    8188    }
    8289
    8390    m_impl->changeVersion(oldVersion, newVersion, callback.release(), errorCallback.release(), successCallback.release());
    84    
     91
    8592    return jsUndefined();
    8693}
     
    8895static JSValue createTransaction(ExecState* exec, const ArgList& args, Database* database, JSDOMGlobalObject* globalObject, bool readOnly)
    8996{
    90     JSObject* object;
    91    
    92     if (!(object = args.at(0).getObject())) {
     97    JSObject* object = args.at(0).getObject();
     98
     99    if (!object) {
    93100        setDOMException(exec, TYPE_MISMATCH_ERR);
    94101        return jsUndefined();
    95     }       
    96      
     102    }
     103
    97104    RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, globalObject));
    98105    RefPtr<SQLTransactionErrorCallback> errorCallback;
    99106    if (args.size() > 1 && !args.at(1).isNull()) {
    100         if (!(object = args.at(1).getObject())) {
     107        object = args.at(1).getObject();
     108        if (!object) {
    101109            setDOMException(exec, TYPE_MISMATCH_ERR);
    102110            return jsUndefined();
     
    108116    RefPtr<VoidCallback> successCallback;
    109117    if (args.size() > 2 && !args.at(2).isNull()) {
    110         if (!(object = args.at(2).getObject())) {
     118        object = args.at(2).getObject();
     119        if (!object) {
    111120            setDOMException(exec, TYPE_MISMATCH_ERR);
    112121            return jsUndefined();
     
    115124        successCallback = JSCustomVoidCallback::create(object, globalObject);
    116125    }
    117    
     126
    118127    database->transaction(callback.release(), errorCallback.release(), successCallback.release(), readOnly);
    119128    return jsUndefined();
     
    122131JSValue JSDatabase::transaction(ExecState* exec, const ArgList& args)
    123132{
    124     return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()), false);
     133    return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), false);
    125134}
    126    
     135
    127136JSValue JSDatabase::readTransaction(ExecState* exec, const ArgList& args)
    128137{
    129     return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()), true);
     138    return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), true);
    130139}
    131140
  • trunk/WebCore/bindings/js/JSSQLTransactionCustom.cpp

    r58801 r59118  
    4242
    4343namespace WebCore {
    44    
     44
    4545JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args)
    4646{
     
    6969        if (exec->hadException())
    7070            return jsUndefined();
    71        
     71
    7272        for (unsigned i = 0 ; i < length; ++i) {
    7373            JSValue value = object->get(exec, i);
    7474            if (exec->hadException())
    7575                return jsUndefined();
    76            
    77             if (value.isNull())
     76
     77            if (value.isUndefinedOrNull())
    7878                sqlValues.append(SQLValue());
    7979            else if (value.isNumber())
     
    9595            return jsUndefined();
    9696        }
    97        
     97
    9898        callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
    9999    }
    100    
     100
    101101    RefPtr<SQLStatementErrorCallback> errorCallback;
    102102    if (!args.at(3).isUndefinedOrNull()) {
     
    106106            return jsUndefined();
    107107        }
    108        
     108
    109109        errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
    110110    }
    111    
     111
    112112    ExceptionCode ec = 0;
    113113    m_impl->executeSQL(sqlStatement, sqlValues, callback.release(), errorCallback.release(), ec);
    114114    setDOMException(exec, ec);
    115    
     115
    116116    return jsUndefined();
    117117}
Note: See TracChangeset for help on using the changeset viewer.