Changeset 86804 in webkit


Ignore:
Timestamp:
May 18, 2011 4:43:23 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-05-18 Mark Pilgrim <pilgrim@chromium.org>

Reviewed by Tony Chang.

IndexedDB put() should fail adding to object store that uses
out-of-line keys and has no key generator and the key parameter
was not provided
https://bugs.webkit.org/show_bug.cgi?id=58609

One new test and one fix to an existing test that relied on the old
broken behavior.

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

2011-05-18 Mark Pilgrim <pilgrim@chromium.org>

Reviewed by Tony Chang.

IndexedDB put() should fail adding to object store that uses
out-of-line keys and has no key generator and the key parameter
was not provided
https://bugs.webkit.org/show_bug.cgi?id=58609

Out-of-line keys means that objectStore->m_keyPath is null in ::put(),
no key generator means that objectStore->autoIncrement() is false, and
key parameter was not provided means that prpKey will be a null pointer.
The combination of these 3 should throw a DATA_ERR.

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

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r86803 r86804  
     12011-05-18  Mark Pilgrim  <pilgrim@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        IndexedDB put() should fail adding to object store that uses
     6        out-of-line keys and has no key generator and the key parameter
     7        was not provided
     8        https://bugs.webkit.org/show_bug.cgi?id=58609
     9
     10        One new test and one fix to an existing test that relied on the old
     11        broken behavior.
     12
     13        * storage/indexeddb/mozilla/key-requirements-put-no-key-expected.txt: Added.
     14        * storage/indexeddb/mozilla/key-requirements-put-no-key.html: Added.
     15        * storage/indexeddb/objectstore-autoincrement-expected.txt:
     16        * storage/indexeddb/objectstore-autoincrement.html:
     17
    1182011-05-18  Siddharth Mathur  <siddharth.mathur@nokia.com>
    219
  • trunk/LayoutTests/storage/indexeddb/objectstore-autoincrement-expected.txt

    r79458 r86804  
    5757store = trans.objectStore('PlainOldStore')
    5858Try adding with no key to object store without auto increment.
    59 store.add({name: 'Adam'})
    60 addAdamError():
    61 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR
    62 event.preventDefault()
     59Expecting exception from store.add({name: 'Adam'})
     60PASS Exception was thrown.
     61PASS code is webkitIDBDatabaseException.DATA_ERR
    6362store.add({name: 'Adam'}, 1)
    6463addAdamSuccess():
  • trunk/LayoutTests/storage/indexeddb/objectstore-autoincrement.html

    r79458 r86804  
    148148    window.store = evalAndLog("store = trans.objectStore('PlainOldStore')");
    149149    debug("Try adding with no key to object store without auto increment.");
    150     request = evalAndLog("store.add({name: 'Adam'})");
    151     request.onsuccess = unexpectedSuccessCallback;
    152     request.onerror = addAdamError;
    153 }
    154 
    155 function addAdamError()
    156 {
    157     debug("addAdamError():");
    158     shouldBe("event.target.errorCode", "webkitIDBDatabaseException.DATA_ERR");
    159 
    160     evalAndLog("event.preventDefault()");
    161 
     150    evalAndExpectException("store.add({name: 'Adam'})", "webkitIDBDatabaseException.DATA_ERR");
    162151    request = evalAndLog("store.add({name: 'Adam'}, 1)");
    163152    request.onsuccess = addAdamSuccess;
  • trunk/Source/WebCore/ChangeLog

    r86801 r86804  
     12011-05-18  Mark Pilgrim  <pilgrim@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        IndexedDB put() should fail adding to object store that uses
     6        out-of-line keys and has no key generator and the key parameter
     7        was not provided
     8        https://bugs.webkit.org/show_bug.cgi?id=58609
     9
     10        Out-of-line keys means that objectStore->m_keyPath is null in ::put(),
     11        no key generator means that objectStore->autoIncrement() is false, and
     12        key parameter was not provided means that prpKey will be a null pointer.
     13        The combination of these 3 should throw a DATA_ERR.
     14
     15        Test: storage/indexeddb/mozilla/key-requirements-put-no-key.html
     16
     17        * storage/IDBObjectStoreBackendImpl.cpp:
     18        (WebCore::IDBObjectStoreBackendImpl::put):
     19
    1202011-05-18  Chris Rogers  <crogers@google.com>
    221
  • trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp

    r86665 r86804  
    136136        return;
    137137    }
     138
     139    const bool autoIncrement = objectStore->autoIncrement();
     140    const bool hasKeyPath = !objectStore->m_keyPath.isNull();
     141    if (!key && !autoIncrement && !hasKeyPath) {
     142        ec = IDBDatabaseException::DATA_ERR;
     143        return;
     144    }
     145
    138146    // FIXME: This should throw a SERIAL_ERR on structured clone problems.
    139147    // 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.