Changeset 62094 in webkit


Ignore:
Timestamp:
Jun 29, 2010 12:39:39 AM (14 years ago)
Author:
dumi@chromium.org
Message:

WebCore: Catch toString() exceptions in all DB-related code.
https://bugs.webkit.org/show_bug.cgi?id=41297

Reviewed by Adam Barth.

  • bindings/v8/custom/V8BindingMacros.h:
  • bindings/v8/custom/V8DOMWindowCustom.cpp:

(WebCore::V8DOMWindow::openDatabaseCallback):

  • bindings/v8/custom/V8DatabaseCustom.cpp:

(WebCore::V8Database::changeVersionCallback):

  • bindings/v8/custom/V8DatabaseSyncCustom.cpp:

(WebCore::V8DatabaseSync::changeVersionCallback):

  • bindings/v8/custom/V8SQLTransactionCustom.cpp:

(WebCore::V8SQLTransaction::executeSqlCallback):

  • bindings/v8/custom/V8SQLTransactionSyncCustom.cpp:

(WebCore::V8SQLTransactionSync::executeSqlCallback):

  • bindings/v8/custom/V8WorkerContextCustom.cpp:

(WebCore::V8WorkerContext::openDatabaseCallback):
(WebCore::V8WorkerContext::openDatabaseSyncCallback):

LayoutTests: Remove a Chromium-specific expectations file.
https://bugs.webkit.org/show_bug.cgi?id=41297

Reviewed by Adam Barth.

  • platform/chromium/storage/sql-error-codes-expected.txt:
  • storage/sql-error-codes.js:

(testBindParameterOfWrongType):

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62092 r62094  
     12010-06-28  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Remove a Chromium-specific expectations file.
     6        https://bugs.webkit.org/show_bug.cgi?id=41297
     7
     8        * platform/chromium/storage/sql-error-codes-expected.txt:
     9        * storage/sql-error-codes.js:
     10        (testBindParameterOfWrongType):
     11
    1122010-06-29  Zoltan Herczeg  <zherczeg@webkit.org>
    213
  • trunk/LayoutTests/platform/chromium/storage/sql-error-codes-expected.txt

    r61352 r62094  
    11CONSOLE MESSAGE: line 37: Uncaught Exception thrown in transaction callback.
     2CONSOLE MESSAGE: line 69: Uncaught Cannot call toString() on this object.
    23This test tests the error codes reported in exceptional situations.
    34PASS: expected and got error code UNKNOWN_ERR
     
    56PASS: expected and got error code SYNTAX_ERR
    67PASS: expected and got error code SYNTAX_ERR
    7 The transaction in testBindParameterOfWrongType() was successful.
     8PASS: expected and got error code UNKNOWN_ERR
    89PASS: expected and got error code QUOTA_ERR
    910PASS: expected and got error code VERSION_ERR
  • trunk/LayoutTests/storage/sql-error-codes.js

    r61352 r62094  
    6565    badString.toString = function() { throw "Cannot call toString() on this object." };
    6666
    67     // JSC will throw an exception when calling badString.toString(). V8 will catch it.
    68     // So we run this transaction using a custom success callback.
    69     db.transaction(function(tx) {
     67    testTransaction(db, function(tx) {
    7068        tx.executeSql("CREATE TABLE IF NOT EXISTS BadBindTypeTest (Foo TEXT)");
    7169        tx.executeSql("INSERT INTO BadBindTypeTest VALUES (?)", [badString]);
    72     }, function(error) {
    73         transactionErrorCallback(error, "UNKNOWN_ERR");
    74     }, function() {
    75         log("The transaction in testBindParameterOfWrongType() was successful.");
    76         testsRun++;
    77     });
     70    }, "UNKNOWN_ERR");
    7871}
    7972
  • trunk/WebCore/ChangeLog

    r62093 r62094  
     12010-06-29  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Catch toString() exceptions in all DB-related code.
     6        https://bugs.webkit.org/show_bug.cgi?id=41297
     7
     8        * bindings/v8/custom/V8BindingMacros.h:
     9        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     10        (WebCore::V8DOMWindow::openDatabaseCallback):
     11        * bindings/v8/custom/V8DatabaseCustom.cpp:
     12        (WebCore::V8Database::changeVersionCallback):
     13        * bindings/v8/custom/V8DatabaseSyncCustom.cpp:
     14        (WebCore::V8DatabaseSync::changeVersionCallback):
     15        * bindings/v8/custom/V8SQLTransactionCustom.cpp:
     16        (WebCore::V8SQLTransaction::executeSqlCallback):
     17        * bindings/v8/custom/V8SQLTransactionSyncCustom.cpp:
     18        (WebCore::V8SQLTransactionSync::executeSqlCallback):
     19        * bindings/v8/custom/V8WorkerContextCustom.cpp:
     20        (WebCore::V8WorkerContext::openDatabaseCallback):
     21        (WebCore::V8WorkerContext::openDatabaseSyncCallback):
     22
    1232010-06-29  Herczeg Zoltan  <zherczeg@webkit.org>
    224
  • trunk/WebCore/bindings/v8/custom/V8BindingMacros.h

    r58989 r62094  
    2929 */
    3030
    31 #define EXCEPTION_BLOCK(type, var, value)         \
    32     type var;                                     \
    33     {                                             \
    34         v8::TryCatch block;                       \
    35         var = value;                              \
    36         if (block.HasCaught())                    \
    37             return throwError(block.Exception()); \
     31#define EXCEPTION_BLOCK(type, var, value) \
     32    type var;                             \
     33    {                                     \
     34        v8::TryCatch block;               \
     35        var = (value);                    \
     36        if (block.HasCaught())            \
     37            return block.ReThrow();      \
    3838    }
     39
     40#define TO_WEBCORE_STRING_EXCEPTION_BLOCK(var, value)                      \
     41    String var;                                                            \
     42    {                                                                      \
     43        v8::TryCatch block;                                                \
     44        v8::Handle<v8::String> v8String = (value)->ToString();             \
     45        if (block.HasCaught())                                             \
     46            return block.ReThrow();                                        \
     47        var = v8StringToWebCoreString<String>(v8String, DoNotExternalize); \
     48    }
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r60902 r62094  
    796796        return throwError(SYNTAX_ERR);
    797797
    798     EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
    799     EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
    800     EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
     798    TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
     799    TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
     800    TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    801801    EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    802802
  • trunk/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp

    r60330 r62094  
    5151        return throwError(SYNTAX_ERR);
    5252
    53     EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0]));
    54     EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1]));
     53    TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]);
     54    TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]);
    5555
    5656    Database* database = V8Database::toNative(args.Holder());
  • trunk/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp

    r60330 r62094  
    4949        return throwError(SYNTAX_ERR);
    5050
    51     EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0]));
    52     EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1]));
     51    TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]);
     52    TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]);
    5353
    5454    DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
  • trunk/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp

    r60330 r62094  
    5555        return throwError(SYNTAX_ERR);
    5656
    57     EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0]));
     57    TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]);
    5858
    5959    Vector<SQLValue> sqlValues;
     
    8282                sqlValues.append(SQLValue(sqlValue));
    8383            } else {
    84                 EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value));
     84                TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value);
    8585                sqlValues.append(SQLValue(sqlValue));
    8686            }
  • trunk/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp

    r59096 r62094  
    5454        return throwError(SYNTAX_ERR);
    5555
    56     EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0]));
     56    TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]);
    5757
    5858    Vector<SQLValue> sqlValues;
     
    8181                sqlValues.append(SQLValue(sqlValue));
    8282            } else {
    83                 EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value));
     83                TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value);
    8484                sqlValues.append(SQLValue(sqlValue));
    8585            }
  • trunk/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp

    r60330 r62094  
    151151        return throwError(SYNTAX_ERR);
    152152
    153     EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
    154     EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
    155     EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
     153    TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
     154    TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
     155    TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    156156    EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    157157
     
    179179        return throwError(SYNTAX_ERR);
    180180
    181     EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
    182     EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
    183     EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
     181    TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
     182    TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
     183    TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    184184    EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    185185
Note: See TracChangeset for help on using the changeset viewer.