Changeset 85234 in webkit


Ignore:
Timestamp:
Apr 28, 2011 1:49:52 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-28 Mark Pilgrim <pilgrim@chromium.org>

Reviewed by Tony Chang.

IndexedDB put() should fail if second (key) parameter is null
https://bugs.webkit.org/show_bug.cgi?id=58613

Added one test and fixed another that relied on old (broken) behavior
when passing null in second parameter.

  • storage/indexeddb/mozilla/key-requirements-put-null-key-expected.txt: Added.
  • storage/indexeddb/mozilla/key-requirements-put-null-key.html: Added.
  • storage/indexeddb/objectstore-basics-expected.txt:
  • storage/indexeddb/objectstore-basics.html:

2011-04-28 Mark Pilgrim <pilgrim@chromium.org>

Reviewed by Tony Chang.

IndexedDB put() should fail if second (key) parameter is null
https://bugs.webkit.org/show_bug.cgi?id=58613

If key arg is not specified, prpKey ends up as a null pointer in ::put().
However, if the key arg is specified but is null, prpKey ends up as a
valid IDBKey which has a null key type. As it happens, we need to be able
to detect the difference between these cases (the key arg is optional but
if specified must not be null).

Test: storage/indexeddb/mozilla/key-requirements-put-null-key.html

  • storage/IDBObjectStoreBackendImpl.cpp: (WebCore::IDBObjectStoreBackendImpl::put):
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85232 r85234  
     12011-04-28  Mark Pilgrim  <pilgrim@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        IndexedDB put() should fail if second (key) parameter is null
     6        https://bugs.webkit.org/show_bug.cgi?id=58613
     7
     8        Added one test and fixed another that relied on old (broken) behavior
     9        when passing null in second parameter.
     10
     11        * storage/indexeddb/mozilla/key-requirements-put-null-key-expected.txt: Added.
     12        * storage/indexeddb/mozilla/key-requirements-put-null-key.html: Added.
     13        * storage/indexeddb/objectstore-basics-expected.txt:
     14        * storage/indexeddb/objectstore-basics.html:
     15
    1162011-04-28  Mark Pilgrim  <pilgrim@chromium.org>
    217
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt

    r80025 r85234  
    6868db.transaction([], webkitIDBTransaction.READ_WRITE)
    6969store = transaction.objectStore('storeName')
    70 store.add({x: 'othervalue'}, null)
    71 addWithNullKeyFailre():
    72 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR
    73 event.preventDefault()
     70Expecting exception from store.add({x: 'othervalue'}, null)
     71PASS Exception was thrown.
     72PASS code is webkitIDBDatabaseException.DATA_ERR
    7473db.transaction([], webkitIDBTransaction.READ_WRITE)
    7574store = transaction.objectStore('storeName')
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics.html

    r80025 r85234  
    186186    var store = evalAndLog("store = transaction.objectStore('storeName')");
    187187
    188     request = evalAndLog("store.add({x: 'othervalue'}, null)");
    189     request.onsuccess = unexpectedSuccessCallback;
    190     request.addEventListener('error', addWithNullKeyFailure, true);
    191 }
    192 
    193 function addWithNullKeyFailure()
    194 {
    195     debug("addWithNullKeyFailre():");
    196     shouldBe("event.target.errorCode", "webkitIDBDatabaseException.DATA_ERR");
    197 
    198     evalAndLog("event.preventDefault()");
     188    evalAndExpectException("store.add({x: 'othervalue'}, null)", "webkitIDBDatabaseException.DATA_ERR");
    199189
    200190    transaction = evalAndLog("db.transaction([], webkitIDBTransaction.READ_WRITE)");
  • trunk/Source/WebCore/ChangeLog

    r85233 r85234  
     12011-04-28  Mark Pilgrim  <pilgrim@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        IndexedDB put() should fail if second (key) parameter is null
     6        https://bugs.webkit.org/show_bug.cgi?id=58613
     7
     8        If key arg is not specified, prpKey ends up as a null pointer in ::put().
     9        However, if the key arg is specified but is null, prpKey ends up as a
     10        valid IDBKey which has a null key type. As it happens, we need to be able
     11        to detect the difference between these cases (the key arg is optional but
     12        if specified must not be null).
     13
     14        Test: storage/indexeddb/mozilla/key-requirements-put-null-key.html
     15
     16        * storage/IDBObjectStoreBackendImpl.cpp:
     17        (WebCore::IDBObjectStoreBackendImpl::put):
     18
    1192011-04-07  David Levin  <levin@chromium.org>
    220
  • trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp

    r85165 r85234  
    131131    RefPtr<IDBCallbacks> callbacks = prpCallbacks;
    132132    RefPtr<IDBTransactionBackendInterface> transaction = transactionPtr;
     133
     134    if (key && (key->type() == IDBKey::NullType)) {
     135        ec = IDBDatabaseException::DATA_ERR;
     136        return;
     137    }
    133138    // FIXME: This should throw a SERIAL_ERR on structured clone problems.
    134139    // FIXME: This should throw a DATA_ERR when the wrong key/keyPath data is supplied.
Note: See TracChangeset for help on using the changeset viewer.