Changeset 122173 in webkit


Ignore:
Timestamp:
Jul 9, 2012 5:48:10 PM (12 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction() should be coerced to string
https://bugs.webkit.org/show_bug.cgi?id=90474

Reviewed by Tony Chang.

Source/WebCore:

Test: storage/indexeddb/transaction-basics.html

  • Modules/indexeddb/IDBDatabase.cpp:

(WebCore::IDBDatabase::transaction):

  • Modules/indexeddb/IDBDatabase.idl:

LayoutTests:

  • storage/indexeddb/resources/transaction-basics.js:

(testInvalidMode):
(testDegenerateNames.request.onsuccess):
(testDegenerateNames.verifyDegenerateNames):
(testDegenerateNames):

  • storage/indexeddb/transaction-basics-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122169 r122173  
     12012-07-09  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction() should be coerced to string
     4        https://bugs.webkit.org/show_bug.cgi?id=90474
     5
     6        Reviewed by Tony Chang.
     7
     8        * storage/indexeddb/resources/transaction-basics.js:
     9        (testInvalidMode):
     10        (testDegenerateNames.request.onsuccess):
     11        (testDegenerateNames.verifyDegenerateNames):
     12        (testDegenerateNames):
     13        * storage/indexeddb/transaction-basics-expected.txt:
     14
    1152012-07-09  Vincent Scheib  <scheib@chromium.org>
    216
  • trunk/LayoutTests/storage/indexeddb/resources/transaction-basics.js

    r121492 r122173  
    281281    debug("Verify that specifying an invalid mode raises an exception");
    282282    evalAndExpectException("db.transaction(['storeName'], 'lsakjdf')", "IDBDatabaseException.TYPE_ERR", "'TypeError'");
    283     finishJSTest();
     283    testDegenerateNames();
     284}
     285
     286function testDegenerateNames()
     287{
     288    debug("");
     289    debug("Test that null and undefined are treated as strings");
     290
     291    evalAndExpectException("db.transaction(null)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
     292    evalAndExpectException("db.transaction(undefined)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
     293
     294    request = evalAndLog("db.setVersion('funny names')");
     295    request.onerror = unexpectedErrorCallback;
     296    request.onsuccess = function () {
     297        var trans = request.result;
     298        evalAndLog("db.createObjectStore('null')");
     299        evalAndLog("db.createObjectStore('undefined')");
     300        trans.oncomplete = verifyDegenerateNames;
     301    };
     302    function verifyDegenerateNames() {
     303        shouldNotThrow("transaction = db.transaction(null)");
     304        shouldBeNonNull("transaction.objectStore('null')");
     305        shouldNotThrow("transaction = db.transaction(undefined)");
     306        shouldBeNonNull("transaction.objectStore('undefined')");
     307        finishJSTest();
     308    }
    284309}
    285310
  • trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt

    r121492 r122173  
    203203PASS code is IDBDatabaseException.TYPE_ERR
    204204PASS ename is 'TypeError'
     205
     206Test that null and undefined are treated as strings
     207Expecting exception from db.transaction(null)
     208PASS Exception was thrown.
     209PASS code is DOMException.NOT_FOUND_ERR
     210PASS ename is 'NotFoundError'
     211Expecting exception from db.transaction(undefined)
     212PASS Exception was thrown.
     213PASS code is DOMException.NOT_FOUND_ERR
     214PASS ename is 'NotFoundError'
     215db.setVersion('funny names')
     216db.createObjectStore('null')
     217db.createObjectStore('undefined')
     218PASS transaction = db.transaction(null) did not throw exception.
     219PASS transaction.objectStore('null') is non-null.
     220PASS transaction = db.transaction(undefined) did not throw exception.
     221PASS transaction.objectStore('undefined') is non-null.
    205222PASS successfullyParsed is true
    206223
  • trunk/Source/WebCore/ChangeLog

    r122172 r122173  
     12012-07-09  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction() should be coerced to string
     4        https://bugs.webkit.org/show_bug.cgi?id=90474
     5
     6        Reviewed by Tony Chang.
     7
     8        Test: storage/indexeddb/transaction-basics.html
     9
     10        * Modules/indexeddb/IDBDatabase.cpp:
     11        (WebCore::IDBDatabase::transaction):
     12        * Modules/indexeddb/IDBDatabase.idl:
     13
    1142012-07-09  Joshua Bell  <jsbell@chromium.org>
    215
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r121488 r122173  
    208208{
    209209    RefPtr<DOMStringList> storeNames = prpStoreNames;
    210     if (!storeNames || storeNames->isEmpty()) {
     210    ASSERT(storeNames.get());
     211    if (storeNames->isEmpty()) {
    211212        ec = IDBDatabaseException::IDB_INVALID_ACCESS_ERR;
    212213        return 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl

    r121817 r122173  
    4646        [CallWith=ScriptExecutionContext] IDBVersionChangeRequest setVersion(in DOMString version)
    4747            raises (IDBDatabaseException);
    48         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
     48        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    4949            raises (IDBDatabaseException);
    50         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
     50        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    5151            raises (IDBDatabaseException);
    5252        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in [Optional=DefaultIsNullString] DOMString mode)
     
    5454
    5555        // FIXME: remove these when https://bugs.webkit.org/show_bug.cgi?id=85326 is fixed.
    56         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in unsigned short mode)
     56        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList storeNames, in unsigned short mode)
    5757            raises (IDBDatabaseException);
    58         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in unsigned short mode)
     58        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in unsigned short mode)
    5959            raises (IDBDatabaseException);
    6060        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in unsigned short mode)
Note: See TracChangeset for help on using the changeset viewer.