Changeset 76531 in webkit


Ignore:
Timestamp:
Jan 24, 2011 11:01:45 AM (13 years ago)
Author:
andreip@google.com
Message:

2011-01-24 Andrei Popescu <andreip@google.com>

Reviewed by Nate Chapin.

IndexedDatabase methods should not take arguments of type OptionsObject
https://bugs.webkit.org/show_bug.cgi?id=53012

  • storage/indexeddb/create-object-store-options-expected.txt:
  • storage/indexeddb/create-object-store-options.html:
  • storage/indexeddb/cursor-delete-expected.txt:
  • storage/indexeddb/cursor-delete.html:
  • storage/indexeddb/cursor-index-delete-expected.txt:
  • storage/indexeddb/cursor-index-delete.html:
  • storage/indexeddb/data-corruption-expected.txt:
  • storage/indexeddb/data-corruption.html:
  • storage/indexeddb/database-quota-expected.txt:
  • storage/indexeddb/database-quota.html:
  • storage/indexeddb/index-cursor.html:
  • storage/indexeddb/objectstore-basics-expected.txt:
  • storage/indexeddb/objectstore-basics.html:
  • storage/indexeddb/objectstore-cursor.html:
  • storage/indexeddb/open-cursor-expected.txt:
  • storage/indexeddb/open-cursor.html:
  • storage/indexeddb/transaction-and-objectstore-calls-expected.txt:
  • storage/indexeddb/transaction-and-objectstore-calls.html:
  • storage/indexeddb/tutorial.html:

2011-01-24 Andrei Popescu <andreip@google.com>

Reviewed by Nate Chapin.

IndexedDatabase methods should not take arguments of type OptionsObject
https://bugs.webkit.org/show_bug.cgi?id=53012

This patch reverts all IDB methods, except IDBDatabase::createObjectStore and
IDBObjectStore::createIndex, to using a plain list of arguments instead of
grouping the various parameters inside a single OptionsObject argument.
This decision was made on public-webapps@w3.org mailing list.

We also add support (v8 only for now) for passing DOMStringList objects as arguments to native
methods. The code for obtaining a DOMStringList object from a JS array of strings existed already
in OptionsObject.cpp, I just copied it to V8Bindings.cpp and taught the v8 code generator how to
use it.

  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/v8/V8Binding.cpp: (WebCore::v8ValueToWebCoreDOMStringList):
  • bindings/v8/V8Binding.h:
  • storage/IDBDatabase.cpp: (WebCore::IDBDatabase::transaction):
  • storage/IDBDatabase.h: (WebCore::IDBDatabase::transaction):
  • storage/IDBDatabase.idl:
  • storage/IDBIndex.cpp: (WebCore::IDBIndex::openCursor): (WebCore::IDBIndex::openKeyCursor):
  • storage/IDBIndex.h: (WebCore::IDBIndex::openCursor): (WebCore::IDBIndex::openKeyCursor):
  • storage/IDBIndex.idl:
  • storage/IDBObjectStore.cpp: (WebCore::IDBObjectStore::openCursor):
  • storage/IDBObjectStore.h: (WebCore::IDBObjectStore::openCursor):
  • storage/IDBObjectStore.idl:
Location:
trunk
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r76528 r76531  
     12011-01-24  Andrei Popescu  <andreip@google.com>
     2
     3        Reviewed by Nate Chapin.
     4
     5        IndexedDatabase methods should not take arguments of type OptionsObject
     6        https://bugs.webkit.org/show_bug.cgi?id=53012
     7
     8        * storage/indexeddb/create-object-store-options-expected.txt:
     9        * storage/indexeddb/create-object-store-options.html:
     10        * storage/indexeddb/cursor-delete-expected.txt:
     11        * storage/indexeddb/cursor-delete.html:
     12        * storage/indexeddb/cursor-index-delete-expected.txt:
     13        * storage/indexeddb/cursor-index-delete.html:
     14        * storage/indexeddb/data-corruption-expected.txt:
     15        * storage/indexeddb/data-corruption.html:
     16        * storage/indexeddb/database-quota-expected.txt:
     17        * storage/indexeddb/database-quota.html:
     18        * storage/indexeddb/index-cursor.html:
     19        * storage/indexeddb/objectstore-basics-expected.txt:
     20        * storage/indexeddb/objectstore-basics.html:
     21        * storage/indexeddb/objectstore-cursor.html:
     22        * storage/indexeddb/open-cursor-expected.txt:
     23        * storage/indexeddb/open-cursor.html:
     24        * storage/indexeddb/transaction-and-objectstore-calls-expected.txt:
     25        * storage/indexeddb/transaction-and-objectstore-calls.html:
     26        * storage/indexeddb/tutorial.html:
     27
    1282011-01-24  Chang Shu  <chang.shu@nokia.com>
    229
  • trunk/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt

    r76126 r76531  
    1818db.createObjectStore('b')
    1919db.createObjectStore('c', {autoIncrement: true});
    20 trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     20trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
    2121PASS trans.mode is webkitIDBTransaction.READ_WRITE
    2222trans.objectStore('a').put({'a': 0})
  • trunk/LayoutTests/storage/indexeddb/create-object-store-options.html

    r76126 r76531  
    4848    db.createObjectStore('c', {autoIncrement: true});
    4949
    50     trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     50    trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)");
    5151    shouldBe("trans.mode", "webkitIDBTransaction.READ_WRITE");
    5252
  • trunk/LayoutTests/storage/indexeddb/cursor-delete-expected.txt

    r76217 r76531  
    4949objectStore.add('myValue4', 'myKey4')
    5050openCursor1
    51 trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
     51trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)
    5252trans.objectStore('test').openCursor({range: keyRange})
    5353PASS 'onsuccess' in result is true
     
    6969event.result.continue()
    7070PASS counter is 5
    71 trans.objectStore('test').openCursor({range: keyRange})
     71trans.objectStore('test').openCursor(keyRange)
    7272PASS 'onsuccess' in result is true
    7373PASS 'onerror' in result is true
     
    8787
    8888PASS event.result is null
    89 trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
     89trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)
    9090objectStore = trans.objectStore('test')
    9191objectStore.add('myValue1', 'myKey1')
     
    9696
    9797openCursor2
    98 objectStore.openCursor({range: keyRange})
     98objectStore.openCursor(keyRange)
    9999PASS 'onsuccess' in result is true
    100100PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/cursor-delete.html

    r76217 r76531  
    6060{
    6161    debug("openCursor1");
    62     evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
     62    evalAndLog("trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)");
    6363    keyRange = webkitIDBKeyRange.lowerBound("myKey1");
    6464    result = evalAndLog("trans.objectStore('test').openCursor({range: keyRange})");
     
    7373    if (event.result == null) {
    7474        shouldBe("counter", "5");
    75         result = evalAndLog("trans.objectStore('test').openCursor({range: keyRange})");
     75        result = evalAndLog("trans.objectStore('test').openCursor(keyRange)");
    7676        verifyResult(result);
    7777        result.onsuccess = cursorEmpty;
     
    9393function addObject()
    9494{
    95     evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
     95    evalAndLog("trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)");
    9696    objectStore = evalAndLog("objectStore = trans.objectStore('test')");
    9797    result = evalAndLog("objectStore.add('myValue1', 'myKey1')");
     
    104104{
    105105    debug("openCursor2");
    106     result = evalAndLog("objectStore.openCursor({range: keyRange})");
     106    result = evalAndLog("objectStore.openCursor(keyRange)");
    107107    verifyResult(result);
    108108    result.onsuccess = deleteObject;
  • trunk/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt

    r75596 r76531  
    5050objectStore.add({x: 4}, 'myKey4')
    5151openCursor1
    52 trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
    53 trans.objectStore('test').index('testIndex').openCursor({range: keyRange})
     52trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)
     53trans.objectStore('test').index('testIndex').openCursor(keyRange)
    5454PASS 'onsuccess' in result is true
    5555PASS 'onerror' in result is true
     
    7070event.result.continue()
    7171PASS counter is 5
    72 trans.objectStore('test').index('testIndex').openCursor({range: keyRange})
     72trans.objectStore('test').index('testIndex').openCursor(keyRange)
    7373PASS 'onsuccess' in result is true
    7474PASS 'onerror' in result is true
     
    8888
    8989PASS event.result is null
    90 trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
     90trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)
    9191objectStore = trans.objectStore('test')
    9292objectStore.add({x: 1}, 'myKey1')
     
    9898openCursor2
    9999index = event.source.index('testIndex')
    100 index.openCursor({range: keyRange})
     100index.openCursor(keyRange)
    101101PASS 'onsuccess' in result is true
    102102PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/cursor-index-delete.html

    r75596 r76531  
    6262{
    6363    debug("openCursor1");
    64     evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
     64    evalAndLog("trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)");
    6565    keyRange = webkitIDBKeyRange.lowerBound(1);
    66     result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor({range: keyRange})");
     66    result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor(keyRange)");
    6767    verifyResult(result);
    6868    result.onsuccess = cursorSuccess;
     
    7575    if (event.result == null) {
    7676        shouldBe("counter", "5");
    77         result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor({range: keyRange})");
     77        result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor(keyRange)");
    7878        verifyResult(result);
    7979        result.onsuccess = cursorEmpty;
     
    9696function addObject()
    9797{
    98     evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
     98    evalAndLog("trans = db.transaction(['test'], webkitIDBTransaction.READ_WRITE)");
    9999    objectStore = evalAndLog("objectStore = trans.objectStore('test')");
    100100    result = evalAndLog("objectStore.add({x: 1}, 'myKey1')");
     
    108108    debug("openCursor2");
    109109    evalAndLog("index = event.source.index('testIndex')");
    110     result = evalAndLog("index.openCursor({range: keyRange})");
     110    result = evalAndLog("index.openCursor(keyRange)");
    111111    verifyResult(result);
    112112    result.onsuccess = deleteObject;
  • trunk/LayoutTests/storage/indexeddb/data-corruption-expected.txt

    r76448 r76531  
    4747db.createObjectStore('storeName')
    4848addData():
    49 transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     49transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
    5050result = transaction.objectStore('storeName').add({x: testDate}, 'key')
    5151addData():
    52 transaction = db.transaction({mode: webkitIDBTransaction.READ_ONLY})
     52transaction = db.transaction([], webkitIDBTransaction.READ_ONLY)
    5353result = transaction.objectStore('storeName').get('key')
    5454Success event fired:
  • trunk/LayoutTests/storage/indexeddb/data-corruption.html

    r76448 r76531  
    5858{
    5959    debug("addData():");
    60     var transaction = evalAndLog("transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     60    var transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)");
    6161    var result = evalAndLog("result = transaction.objectStore('storeName').add({x: testDate}, 'key')");
    6262    result.onerror = unexpectedErrorCallback;
     
    6767{
    6868    debug("addData():");
    69     var transaction = evalAndLog("transaction = db.transaction({mode: webkitIDBTransaction.READ_ONLY})");
     69    var transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_ONLY)");
    7070    var result = evalAndLog("result = transaction.objectStore('storeName').get('key')");
    7171    result.onerror = unexpectedErrorCallback;
  • trunk/LayoutTests/storage/indexeddb/database-quota-expected.txt

    r75596 r76531  
    6565PASS db.objectStoreNames.contains('test456') is false
    6666PASS db.objectStoreNames.contains('test123') is true
    67 trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     67trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
    6868Creating 'data' which contains 64K of data
    6969PASS data.length is 65536
  • trunk/LayoutTests/storage/indexeddb/database-quota.html

    r75596 r76531  
    7575function checkQuotaEnforcing()
    7676{
    77     var trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     77    var trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)");
    7878    trans.onabort = testComplete;
    7979    trans.oncomplete = unexpectedCompleteCallback;
  • trunk/LayoutTests/storage/indexeddb/index-cursor.html

    r73697 r76531  
    188188        keyRange = webkitIDBKeyRange.upperBound(testData[upper], upperIsOpen);
    189189 
    190     var request = indexObject.openKeyCursor({range: keyRange, direction: ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV});
     190    var request = indexObject.openKeyCursor(keyRange, ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV);
    191191    request.onsuccess = cursorIteration;
    192192    request.onerror = unexpectedErrorCallback;
     
    255255    debug(str);
    256256 
    257     var request = indexObject.openKeyCursor({direction: ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV});
     257    var request = indexObject.openKeyCursor(null, ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV);
    258258    request.onsuccess = cursorIteration;
    259259    request.onerror = unexpectedErrorCallback;
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt

    r75596 r76531  
    9696PASS store.indexNames.item(1) is null
    9797PASS store.indexNames.item(100) is null
    98 transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     98transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
    9999store = transaction.objectStore('storeName')
    100100Try to insert data with a Date key:
     
    138138
    139139PASS event.code is webkitIDBDatabaseException.UNKNOWN_ERR
    140 db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     140db.transaction([], webkitIDBTransaction.READ_WRITE)
    141141store = transaction.objectStore('storeName')
    142142store.add({x: 'othervalue'}, null)
     
    159159
    160160PASS event.code is webkitIDBDatabaseException.DATA_ERR
    161 db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     161db.transaction([], webkitIDBTransaction.READ_WRITE)
    162162store = transaction.objectStore('storeName')
    163163store.add({x: null}, 'validkey')
     
    180180
    181181PASS event.code is webkitIDBDatabaseException.DATA_ERR
    182 db.transaction({mode: webkitIDBTransaction.READ_WRITE})
     182db.transaction([], webkitIDBTransaction.READ_WRITE)
    183183store = transaction.objectStore('storeName')
    184184store.get('key')
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics.html

    r75596 r76531  
    142142function addData()
    143143{
    144     var transaction = evalAndLog("transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     144    var transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)");
    145145    transaction.onabort = unexpectedAbortCallback;
    146146    window.store = evalAndLog("store = transaction.objectStore('storeName')");
     
    190190    shouldBe("event.code", "webkitIDBDatabaseException.UNKNOWN_ERR");
    191191
    192     transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     192    transaction = evalAndLog("db.transaction([], webkitIDBTransaction.READ_WRITE)");
    193193    transaction.onabort = unexpectedErrorCallback;
    194194    var store = evalAndLog("store = transaction.objectStore('storeName')");
     
    206206    shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR");
    207207
    208     transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     208    transaction = evalAndLog("db.transaction([], webkitIDBTransaction.READ_WRITE)");
    209209    transaction.onabort = unexpectedErrorCallback;
    210210    var store = evalAndLog("store = transaction.objectStore('storeName')");
     
    222222    shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR");
    223223
    224     transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     224    transaction = evalAndLog("db.transaction([], webkitIDBTransaction.READ_WRITE)");
    225225    transaction.onabort = unexpectedErrorCallback;
    226226    var store = evalAndLog("store = transaction.objectStore('storeName')");
  • trunk/LayoutTests/storage/indexeddb/objectstore-cursor.html

    r73697 r76531  
    166166        keyRange = webkitIDBKeyRange.upperBound(testData[upper], upperIsOpen);
    167167 
    168     var request = objectStore.openCursor({range: keyRange, direction: ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV});
     168    var request = objectStore.openCursor(keyRange, ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV);
    169169    request.onsuccess = cursorIteration;
    170170    request.onerror = unexpectedErrorCallback;
     
    232232    debug(str);
    233233 
    234     var request = objectStore.openCursor({direction: ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV});
     234    var request = objectStore.openCursor(null, ascending ? webkitIDBCursor.NEXT : webkitIDBCursor.PREV);
    235235    request.onsuccess = cursorIteration;
    236236    request.onerror = unexpectedErrorCallback;
  • trunk/LayoutTests/storage/indexeddb/open-cursor-expected.txt

    r72766 r76531  
    5151
    5252Opening cursor
    53 event.source.openCursor({range: keyRange})
     53event.source.openCursor(keyRange)
    5454PASS 'onsuccess' in result is true
    5555PASS 'onerror' in result is true
     
    7777
    7878Opening an empty cursor.
    79 objectStore.openCursor({range: keyRange})
     79objectStore.openCursor(keyRange)
    8080PASS 'onsuccess' in result is true
    8181PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/open-cursor.html

    r72767 r76531  
    2727    debug("Opening an empty cursor.");
    2828    keyRange = webkitIDBKeyRange.lowerBound("InexistentKey");
    29     result = evalAndLog("objectStore.openCursor({range: keyRange})");
     29    result = evalAndLog("objectStore.openCursor(keyRange)");
    3030    verifyResult(result);
    3131    result.onsuccess = emptyCursorSuccess;
     
    5757    debug("Opening cursor");
    5858    keyRange = webkitIDBKeyRange.lowerBound("myKey");
    59     result = evalAndLog("event.source.openCursor({range: keyRange})");
     59    result = evalAndLog("event.source.openCursor(keyRange)");
    6060    verifyResult(result);
    6161    result.onsuccess = cursorSuccess;
  • trunk/LayoutTests/storage/indexeddb/transaction-and-objectstore-calls-expected.txt

    r72765 r76531  
    2020trans.oncomplete = created
    2121
    22 trans = db.transaction({objectStoreNames: 'a'})
     22trans = db.transaction(['a'])
    2323trans.objectStore('a')
    2424Expecting exception from trans.objectStore('b')
     
    2727PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    2828
    29 trans = db.transaction({objectStoreNames: ['a']})
     29trans = db.transaction(['a'])
    3030trans.objectStore('a')
    3131Expecting exception from trans.objectStore('b')
     
    3434PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    3535
    36 trans = db.transaction({objectStoreNames: ['b']})
     36trans = db.transaction(['b'])
    3737trans.objectStore('b')
    3838Expecting exception from trans.objectStore('a')
     
    4141PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    4242
    43 trans = db.transaction({objectStoreNames: ['a', 'b']})
     43trans = db.transaction(['a', 'b'])
    4444trans.objectStore('a')
    4545trans.objectStore('b')
     
    4747PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    4848
    49 trans = db.transaction({objectStoreNames: ['b', 'a']})
     49trans = db.transaction(['b', 'a'])
    5050trans.objectStore('a')
    5151trans.objectStore('b')
     
    5353PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    5454
    55 trans = db.transaction({objectStoreNames: []})
     55trans = db.transaction([])
    5656trans.objectStore('a')
    5757trans.objectStore('b')
     
    6565PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    6666
    67 Expecting exception from db.transaction({objectStoreNames: 'x'})
     67Expecting exception from db.transaction(['x'])
    6868PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    69 Expecting exception from db.transaction({objectStoreNames: ['x']})
     69Expecting exception from db.transaction(['x'])
    7070PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    71 Expecting exception from db.transaction({objectStoreNames: ['a', 'x']})
     71Expecting exception from db.transaction(['a', 'x'])
    7272PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    73 Expecting exception from db.transaction({objectStoreNames: ['x', 'x']})
     73Expecting exception from db.transaction(['x', 'x'])
    7474PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    75 Expecting exception from db.transaction({objectStoreNames: ['a', 'x', 'b']})
     75Expecting exception from db.transaction(['a', 'x', 'b'])
    7676PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
    7777
  • trunk/LayoutTests/storage/indexeddb/transaction-and-objectstore-calls.html

    r72765 r76531  
    5050function created()
    5151{
    52     trans = evalAndLog("trans = db.transaction({objectStoreNames: 'a'})");
     52    trans = evalAndLog("trans = db.transaction(['a'])");
    5353    evalAndLog("trans.objectStore('a')");
    5454    evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     
    5656    debug("");
    5757
    58     trans = evalAndLog("trans = db.transaction({objectStoreNames: ['a']})");
     58    trans = evalAndLog("trans = db.transaction(['a'])");
    5959    evalAndLog("trans.objectStore('a')");
    6060    evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     
    6262    debug("");
    6363
    64     trans = evalAndLog("trans = db.transaction({objectStoreNames: ['b']})");
     64    trans = evalAndLog("trans = db.transaction(['b'])");
    6565    evalAndLog("trans.objectStore('b')");
    6666    evalAndExpectException("trans.objectStore('a')", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     
    6868    debug("");
    6969
    70     trans = evalAndLog("trans = db.transaction({objectStoreNames: ['a', 'b']})");
     70    trans = evalAndLog("trans = db.transaction(['a', 'b'])");
    7171    evalAndLog("trans.objectStore('a')");
    7272    evalAndLog("trans.objectStore('b')");
     
    7474    debug("");
    7575
    76     trans = evalAndLog("trans = db.transaction({objectStoreNames: ['b', 'a']})");
     76    trans = evalAndLog("trans = db.transaction(['b', 'a'])");
    7777    evalAndLog("trans.objectStore('a')");
    7878    evalAndLog("trans.objectStore('b')");
     
    8080    debug("");
    8181
    82     trans = evalAndLog("trans = db.transaction({objectStoreNames: []})");
     82    trans = evalAndLog("trans = db.transaction([])");
    8383    evalAndLog("trans.objectStore('a')");
    8484    evalAndLog("trans.objectStore('b')");
     
    9292    debug("");
    9393
    94     evalAndExpectException("db.transaction({objectStoreNames: 'x'})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    95     evalAndExpectException("db.transaction({objectStoreNames: ['x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    96     evalAndExpectException("db.transaction({objectStoreNames: ['a', 'x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    97     evalAndExpectException("db.transaction({objectStoreNames: ['x', 'x']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    98     evalAndExpectException("db.transaction({objectStoreNames: ['a', 'x', 'b']})", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     94    evalAndExpectException("db.transaction(['x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     95    evalAndExpectException("db.transaction(['x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     96    evalAndExpectException("db.transaction(['a', 'x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     97    evalAndExpectException("db.transaction(['x', 'x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR");
     98    evalAndExpectException("db.transaction(['a', 'x', 'b'])", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    9999    debug("");
    100100
  • trunk/LayoutTests/storage/indexeddb/tutorial.html

    r72785 r76531  
    208208    // Lets create a new transaction and then not schedule any work on it to watch it abort itself.
    209209    // Transactions (besides those created with setVersion) are created synchronously. Like
    210     // createObjectStore, transaction optionally takes in an object with various optional parameters.
     210    // createObjectStore, transaction optionally takes in various optional parameters.
    211211    //
    212212    // First of all is the parameter "objectStoreNames". If you pass in a string, we lock just that
     
    223223    // means never, but it's possible we'll change this in the future and other implementations may
    224224    // use something different, so set it if you really care.
    225     window.currentTransaction = db.transaction({mode: IDBTransaction.READ_WRITE, timeout: 0});
     225    window.currentTransaction = db.transaction([], IDBTransaction.READ_WRITE, 0);
    226226    currentTransaction.oncomplete = unexpectedComplete;
    227227    currentTransaction.onabort = onTransactionAborted;
     
    273273    // we'll omit the objectStoreNames parameter which means we'll lock everything even though we only
    274274    // ever access "people".
    275     window.currentTransaction = db.transaction({mode: IDBTransaction.READ_WRITE});
     275    window.currentTransaction = db.transaction([], IDBTransaction.READ_WRITE);
    276276    currentTransaction.onabort = unexpectedAbort;
    277277
     
    311311    // It simply takes in a key and returns a request whose result will be the value. Note that here
    312312    // we're passing in an array for objectStoreNames rather than a simple string.
    313     window.currentTransaction = db.transaction({objectStoreNames: ["people"], mode: IDBTransaction.READ_WRITE, timeout: 0});
     313    window.currentTransaction = db.transaction(["people"], IDBTransaction.READ_WRITE, 0);
    314314    currentTransaction.onabort = unexpectedAbort;
    315315
     
    342342    // and PREV_NO_DUPLICATE.
    343343    var keyRange = IDBKeyRange.bound(1, 3, true, false);
    344     var request = people.openCursor({range: keyRange, direction: IDBCursor.NEXT});
     344    var request = people.openCursor(keyRange, IDBCursor.NEXT);
    345345    request.onsuccess = onObjectStoreCursor;
    346346    request.onerror = unexpectedError;
     
    395395    // the onsuccess conditions.
    396396    var lname = event.source;
    397     lname.openCursor({range: IDBKeyRange.lowerBound("Doe", false), direction: IDBCursor.NEXT_NO_DUPLICATE});
    398     lname.openCursor({direction: IDBCursor.PREV_NO_DUPLICATE});
    399     lname.openCursor({range: IDBKeyRange.upperBound("ZZZZ")});
    400     lname.openCursor({range: IDBKeyRange.only("Doe"), direction: IDBCursor.PREV});
     397    lname.openCursor(IDBKeyRange.lowerBound("Doe", false), IDBCursor.NEXT_NO_DUPLICATE);
     398    lname.openCursor(null, IDBCursor.PREV_NO_DUPLICATE);
     399    lname.openCursor(IDBKeyRange.upperBound("ZZZZ"));
     400    lname.openCursor(IDBKeyRange.only("Doe"), IDBCursor.PREV);
    401401    lname.openCursor();
    402402    lname.openKeyCursor();
  • trunk/Source/WebCore/ChangeLog

    r76519 r76531  
     12011-01-24  Andrei Popescu  <andreip@google.com>
     2
     3        Reviewed by Nate Chapin.
     4
     5        IndexedDatabase methods should not take arguments of type OptionsObject
     6        https://bugs.webkit.org/show_bug.cgi?id=53012
     7
     8        This patch reverts all IDB methods, except IDBDatabase::createObjectStore and
     9        IDBObjectStore::createIndex, to using a plain list of arguments instead of
     10        grouping the various parameters inside a single OptionsObject argument.
     11        This decision was made on public-webapps@w3.org mailing list.
     12
     13        We also add support (v8 only for now) for passing DOMStringList objects as arguments to native
     14        methods. The code for obtaining a DOMStringList object from a JS array of strings existed already
     15        in OptionsObject.cpp, I just copied it to V8Bindings.cpp and taught the v8 code generator how to
     16        use it.
     17
     18        * bindings/scripts/CodeGeneratorV8.pm:
     19        * bindings/v8/V8Binding.cpp:
     20        (WebCore::v8ValueToWebCoreDOMStringList):
     21        * bindings/v8/V8Binding.h:
     22        * storage/IDBDatabase.cpp:
     23        (WebCore::IDBDatabase::transaction):
     24        * storage/IDBDatabase.h:
     25        (WebCore::IDBDatabase::transaction):
     26        * storage/IDBDatabase.idl:
     27        * storage/IDBIndex.cpp:
     28        (WebCore::IDBIndex::openCursor):
     29        (WebCore::IDBIndex::openKeyCursor):
     30        * storage/IDBIndex.h:
     31        (WebCore::IDBIndex::openCursor):
     32        (WebCore::IDBIndex::openKeyCursor):
     33        * storage/IDBIndex.idl:
     34        * storage/IDBObjectStore.cpp:
     35        (WebCore::IDBObjectStore::openCursor):
     36        * storage/IDBObjectStore.h:
     37        (WebCore::IDBObjectStore::openCursor):
     38        * storage/IDBObjectStore.idl:
     39
    1402011-01-24  Pavel Feldman  <pfeldman@chromium.org>
    241
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r76277 r76531  
    28332833    return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener";
    28342834
     2835    return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
     2836
    28352837    # Default, assume native type is a pointer with same type name as idl type
    28362838    return "${type}*";
     
    28862888    return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType";
    28872889    return "toWebCoreDate($value)" if $type eq "Date";
     2890    return "v8ValueToWebCoreDOMStringList($value)" if $type eq "DOMStringList";
    28882891
    28892892    if ($type eq "DOMString" or $type eq "DOMUserData") {
  • trunk/Source/WebCore/bindings/v8/V8Binding.cpp

    r72354 r76531  
    3232#include "V8Binding.h"
    3333
     34#include "DOMStringList.h"
    3435#include "Element.h"
    3536#include "MathExtras.h"
     
    579580}
    580581
     582PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value> value)
     583{
     584    v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value));
     585    if (!v8Value->IsArray())
     586        return 0;
     587
     588    RefPtr<DOMStringList> ret = DOMStringList::create();
     589    v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value);
     590    for (size_t i = 0; i < v8Array->Length(); ++i) {
     591        v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(i));
     592        ret->append(v8ValueToWebCoreString(indexedValue));
     593    }
     594    return ret.release();
     595}
     596
    581597} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r74833 r76531  
    4242namespace WebCore {
    4343
     44    class DOMStringList;
    4445    class EventListener;
    4546    class EventTarget;
     
    207208    String int32ToWebCoreString(int value);
    208209
     210    PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value>);
     211
    209212    class V8ParameterBase {
    210213    public:
  • trunk/Source/WebCore/storage/IDBDatabase.cpp

    r76126 r76531  
    9999}
    100100
    101 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, const OptionsObject& options, ExceptionCode& ec)
     101PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, PassRefPtr<DOMStringList> prpStoreNames, unsigned short mode, unsigned long timeout, ExceptionCode& ec)
    102102{
    103     RefPtr<DOMStringList> storeNames = options.getKeyDOMStringList("objectStoreNames");
    104     if (!storeNames) {
     103    RefPtr<DOMStringList> storeNames = prpStoreNames;
     104    if (!storeNames)
    105105        storeNames = DOMStringList::create();
    106         String storeName;
    107         if (options.getKeyString("objectStoreNames", storeName))
    108             storeNames->append(storeName);
    109     }
    110106
    111     // Gets cast to an unsigned short.
    112     int32_t mode = IDBTransaction::READ_ONLY;
    113     options.getKeyInt32("mode", mode);
    114107    if (mode != IDBTransaction::READ_WRITE && mode != IDBTransaction::READ_ONLY) {
    115108        // FIXME: May need to change when specced: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11406
     
    117110        return 0;
    118111    }
    119 
    120     // Gets cast to an unsigned long.
    121     // FIXME: The spec needs to be updated on this. It should probably take a double.
    122     int32_t timeout = defaultTimeout;
    123     options.getKeyInt32("timeout", timeout);
    124     int64_t unsignedLongMax = std::numeric_limits<unsigned long>::max();
    125     if (timeout < 0 || timeout > unsignedLongMax)
    126         timeout = defaultTimeout; // Ignore illegal values.
    127112
    128113    // We need to create a new transaction synchronously. Locks are acquired asynchronously. Operations
  • trunk/Source/WebCore/storage/IDBDatabase.h

    r72771 r76531  
    6262    // FIXME: Try to modify the code generator so this is unneeded.
    6363    PassRefPtr<IDBObjectStore> createObjectStore(const String& name, ExceptionCode& ec) { return createObjectStore(name, OptionsObject(), ec); }
    64     PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, ExceptionCode& ec) { return transaction(context, OptionsObject(), ec); }
     64    PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, ExceptionCode& ec) { return transaction(context, 0, ec); }
     65    PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, PassRefPtr<DOMStringList> storeNames, ExceptionCode& ec) { return transaction(context, storeNames, IDBTransaction::READ_ONLY, ec); }
     66    PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, PassRefPtr<DOMStringList> storeNames, unsigned short mode, ExceptionCode& ec) { return transaction(context, storeNames, mode, 0, ec); }
     67    PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, PassRefPtr<DOMStringList>, unsigned short mode, unsigned long timeout, ExceptionCode&);
    6568
    6669    PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const OptionsObject&, ExceptionCode&);
    6770    void deleteObjectStore(const String& name, ExceptionCode&);
    6871    PassRefPtr<IDBRequest> setVersion(ScriptExecutionContext*, const String& version, ExceptionCode&);
    69     PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const OptionsObject&, ExceptionCode&);
    7072    void close();
    7173
  • trunk/Source/WebCore/storage/IDBDatabase.idl

    r75596 r76531  
    3939        [CallWith=ScriptExecutionContext] IDBRequest setVersion(in DOMString version)
    4040            raises (IDBDatabaseException);
    41         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in [Optional] OptionsObject optionsObject)
     41        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in [Optional] DOMStringList storeNames, in [Optional] unsigned short mode, in [Optional] unsigned long timeout)
    4242            raises (IDBDatabaseException);
    4343        // FIXME: Implement.
  • trunk/Source/WebCore/storage/IDBIndex.cpp

    r72769 r76531  
    5353}
    5454
    55 PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, const OptionsObject& options, ExceptionCode& ec)
     55PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, unsigned short direction, ExceptionCode& ec)
    5656{
    57     RefPtr<IDBKeyRange> keyRange = options.getKeyKeyRange("range");
    58 
    59     // Converted to an unsigned short.
    60     int32_t direction = defaultDirection;
    61     options.getKeyInt32("direction", direction);
    6257    if (direction != IDBCursor::NEXT && direction != IDBCursor::NEXT_NO_DUPLICATE && direction != IDBCursor::PREV && direction != IDBCursor::PREV_NO_DUPLICATE) {
    6358        // FIXME: May need to change when specced: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11406
     
    7368}
    7469
    75 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, const OptionsObject& options, ExceptionCode& ec)
     70PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, unsigned short direction, ExceptionCode& ec)
    7671{
    77     RefPtr<IDBKeyRange> keyRange = options.getKeyKeyRange("range");
    78 
    79     // Converted to an unsigned short.
    80     int32_t direction = defaultDirection;
    81     options.getKeyInt32("direction", direction);
    8272    if (direction != IDBCursor::NEXT && direction != IDBCursor::NEXT_NO_DUPLICATE && direction != IDBCursor::PREV && direction != IDBCursor::PREV_NO_DUPLICATE) {
    8373        // FIXME: May need to change when specced: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11406
  • trunk/Source/WebCore/storage/IDBIndex.h

    r72766 r76531  
    3131#include "IDBKeyRange.h"
    3232#include "IDBRequest.h"
    33 #include "OptionsObject.h"
    3433#include "PlatformString.h"
    3534#include <wtf/Forward.h>
     
    5453
    5554    // FIXME: Try to modify the code generator so this is unneeded.
    56     PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, OptionsObject(), ec); }
    57     PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openKeyCursor(context, OptionsObject(), ec); }
     55    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, 0, ec); }
     56    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::NEXT, ec); }
     57    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, unsigned short direction, ExceptionCode&);
    5858
    59     PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const OptionsObject&, ExceptionCode&);
    60     PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, const OptionsObject&, ExceptionCode&);
     59    PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openKeyCursor(context, 0, ec); }
     60    PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openKeyCursor(context, keyRange, IDBCursor::NEXT, ec); }
     61    PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, unsigned short direction, ExceptionCode&);
     62
    6163    PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
    6264    PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
  • trunk/Source/WebCore/storage/IDBIndex.idl

    r72766 r76531  
    3434        readonly attribute boolean unique;
    3535
    36         [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] OptionsObject options)
     36        [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] IDBKeyRange range, in [Optional] unsigned short direction)
    3737            raises (IDBDatabaseException);
    38         [CallWith=ScriptExecutionContext] IDBRequest openKeyCursor(in [Optional] OptionsObject options)
     38        [CallWith=ScriptExecutionContext] IDBRequest openKeyCursor(in [Optional] IDBKeyRange range, in [Optional] unsigned short direction))
    3939            raises (IDBDatabaseException);
    4040        [CallWith=ScriptExecutionContext] IDBRequest get(in IDBKey key)
  • trunk/Source/WebCore/storage/IDBObjectStore.cpp

    r72771 r76531  
    130130}
    131131
    132 PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const OptionsObject& options, ExceptionCode& ec)
     132PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, unsigned short direction, ExceptionCode& ec)
    133133{
    134     RefPtr<IDBKeyRange> range = options.getKeyKeyRange("range");
    135 
    136     // Converted to an unsigned short.
    137     int32_t direction = defaultDirection;
    138     options.getKeyInt32("direction", direction);
    139134    if (direction != IDBCursor::NEXT && direction != IDBCursor::NEXT_NO_DUPLICATE && direction != IDBCursor::PREV && direction != IDBCursor::PREV_NO_DUPLICATE) {
    140135        // FIXME: May need to change when specced: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11406
  • trunk/Source/WebCore/storage/IDBObjectStore.h

    r72771 r76531  
    6464    PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return put(context, value, 0, ec);  }
    6565    PassRefPtr<IDBIndex> createIndex(const String& name, const String& keyPath, ExceptionCode& ec) { return createIndex(name, keyPath, OptionsObject(), ec); }
    66     PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, OptionsObject(), ec); }
     66    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, 0, ec); }
     67    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::NEXT, ec); }
    6768
    6869    PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
     
    7576    void deleteIndex(const String& name, ExceptionCode&);
    7677
    77     PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const OptionsObject&, ExceptionCode&);
     78    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, unsigned short direction, ExceptionCode&);
    7879
    7980private:
  • trunk/Source/WebCore/storage/IDBObjectStore.idl

    r72771 r76531  
    4141        [CallWith=ScriptExecutionContext] IDBRequest get(in IDBKey key)
    4242            raises (IDBDatabaseException);
    43         [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] OptionsObject options)
     43        [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] IDBKeyRange range, in [Optional] unsigned short direction)
    4444            raises (IDBDatabaseException);
    4545        IDBIndex createIndex(in DOMString name, in [ConvertNullToNullString] DOMString keyPath, in [Optional] OptionsObject options)
Note: See TracChangeset for help on using the changeset viewer.