Diff
Modified: trunk/LayoutTests/ChangeLog (108851 => 108852)
--- trunk/LayoutTests/ChangeLog 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/LayoutTests/ChangeLog 2012-02-24 22:56:00 UTC (rev 108852)
@@ -1,3 +1,15 @@
+2012-02-24 Joshua Bell <[email protected]>
+
+ IndexedDB: IDBObjectStore.count() and IDBIndex.count() should accept key argument
+ https://bugs.webkit.org/show_bug.cgi?id=79422
+
+ Reviewed by Tony Chang.
+
+ * storage/indexeddb/index-count-expected.txt:
+ * storage/indexeddb/index-count.html:
+ * storage/indexeddb/objectstore-count-expected.txt:
+ * storage/indexeddb/objectstore-count.html:
+
2012-02-24 Abhishek Arya <[email protected]>
Overhanging floats not removed from new flex box.
Modified: trunk/LayoutTests/storage/indexeddb/index-count-expected.txt (108851 => 108852)
--- trunk/LayoutTests/storage/indexeddb/index-count-expected.txt 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/LayoutTests/storage/indexeddb/index-count-expected.txt 2012-02-24 22:56:00 UTC (rev 108852)
@@ -6,6 +6,7 @@
window.indexedDB = window.indexedDB || window.webkitIndexedDB
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange
+window.IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException
indexedDB.open('index-count')
db = event.target.result
db.setVersion('new version')
@@ -82,6 +83,38 @@
request = index.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result == 'number' is true
PASS request.result is 0
+
+verifying count with key
+trans = db.transaction('storeName', IDBTransaction.READ_ONLY)
+PASS trans != null is true
+store = trans.objectStore('storeName')
+PASS store != null is true
+index = trans.objectStore('storeName').index('indexName')
+PASS index != null is true
+Expecting exception from index.count(NaN)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+Expecting exception from index.count({})
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+Expecting exception from index.count(/regex/)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+
+test = {"key":0,"expected":1}
+request = index.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 1
+
+test = {"key":100,"expected":0}
+request = index.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 0
+
+test = {"key":null,"expected":100}
+request = index.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 100
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/index-count.html (108851 => 108852)
--- trunk/LayoutTests/storage/indexeddb/index-count.html 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/LayoutTests/storage/indexeddb/index-count.html 2012-02-24 22:56:00 UTC (rev 108852)
@@ -17,6 +17,7 @@
evalAndLog("window.indexedDB = window.indexedDB || window.webkitIndexedDB");
evalAndLog("window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction");
evalAndLog("window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange");
+ evalAndLog("window.IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException");
request = evalAndLog("indexedDB.open('index-count')");
request._onerror_ = unexpectedErrorCallback;
request._onsuccess_ = function() {
@@ -79,7 +80,7 @@
trans = evalAndLog("trans = db.transaction('storeName', IDBTransaction.READ_ONLY)");
shouldBeTrue("trans != null");
trans._onabort_ = unexpectedAbortCallback;
- trans._oncomplete_ = done;
+ trans._oncomplete_ = verifyCountWithKey;
store = evalAndLog("store = trans.objectStore('storeName')");
shouldBeTrue("store != null");
@@ -117,6 +118,49 @@
nextTest();
}
+function verifyCountWithKey()
+{
+ debug("");
+ debug("verifying count with key");
+ trans = evalAndLog("trans = db.transaction('storeName', IDBTransaction.READ_ONLY)");
+ shouldBeTrue("trans != null");
+ trans._onabort_ = unexpectedAbortCallback;
+ trans._oncomplete_ = done;
+
+ store = evalAndLog("store = trans.objectStore('storeName')");
+ shouldBeTrue("store != null");
+ store = evalAndLog("index = trans.objectStore('storeName').index('indexName')");
+ shouldBeTrue("index != null");
+
+ evalAndExpectException("index.count(NaN)", "IDBDatabaseException.DATA_ERR");
+ evalAndExpectException("index.count({})", "IDBDatabaseException.DATA_ERR");
+ evalAndExpectException("index.count(/regex/)", "IDBDatabaseException.DATA_ERR");
+
+ var tests = [
+ { key: 0, expected: 1 },
+ { key: 100, expected: 0 },
+ { key: null, expected: 100 }
+ ];
+
+ function nextTest() {
+ debug("");
+ evalAndLog("test = " + JSON.stringify(tests.shift()));
+ request = evalAndLog("request = index.count(test.key)");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function() {
+ shouldBeTrue("typeof request.result == 'number'");
+ shouldBe("request.result", String(test.expected));
+
+ if (tests.length) {
+ nextTest();
+ }
+ // otherwise let the transaction complete
+ };
+ }
+
+ nextTest();
+}
+
test();
</script>
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-count-expected.txt (108851 => 108852)
--- trunk/LayoutTests/storage/indexeddb/objectstore-count-expected.txt 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-count-expected.txt 2012-02-24 22:56:00 UTC (rev 108852)
@@ -6,6 +6,7 @@
window.indexedDB = window.indexedDB || window.webkitIndexedDB
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange
+window.IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException
indexedDB.open('objectstore-count')
db = event.target.result
db.setVersion('new version')
@@ -76,6 +77,36 @@
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result == 'number' is true
PASS request.result is 0
+
+verifying count with key
+trans = db.transaction('storeName', IDBTransaction.READ_ONLY)
+PASS trans != null is true
+store = trans.objectStore('storeName')
+PASS store != null is true
+Expecting exception from store.count(NaN)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+Expecting exception from store.count({})
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+Expecting exception from store.count(/regex/)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+
+test = {"key":0,"expected":1}
+request = store.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 1
+
+test = {"key":100,"expected":0}
+request = store.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 0
+
+test = {"key":null,"expected":100}
+request = store.count(test.key)
+PASS typeof request.result == 'number' is true
+PASS request.result is 100
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-count.html (108851 => 108852)
--- trunk/LayoutTests/storage/indexeddb/objectstore-count.html 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-count.html 2012-02-24 22:56:00 UTC (rev 108852)
@@ -17,6 +17,7 @@
evalAndLog("window.indexedDB = window.indexedDB || window.webkitIndexedDB");
evalAndLog("window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction");
evalAndLog("window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange");
+ evalAndLog("window.IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException");
request = evalAndLog("indexedDB.open('objectstore-count')");
request._onerror_ = unexpectedErrorCallback;
request._onsuccess_ = function() {
@@ -74,7 +75,7 @@
trans = evalAndLog("trans = db.transaction('storeName', IDBTransaction.READ_ONLY)");
shouldBeTrue("trans != null");
trans._onabort_ = unexpectedAbortCallback;
- trans._oncomplete_ = done;
+ trans._oncomplete_ = verifyCountWithKey;
store = evalAndLog("store = trans.objectStore('storeName')");
shouldBeTrue("store != null");
@@ -110,6 +111,46 @@
nextTest();
}
+function verifyCountWithKey()
+{
+ debug("");
+ debug("verifying count with key");
+ trans = evalAndLog("trans = db.transaction('storeName', IDBTransaction.READ_ONLY)");
+ shouldBeTrue("trans != null");
+ trans._onabort_ = unexpectedAbortCallback;
+ trans._oncomplete_ = done;
+
+ store = evalAndLog("store = trans.objectStore('storeName')");
+ shouldBeTrue("store != null");
+
+ evalAndExpectException("store.count(NaN)", "IDBDatabaseException.DATA_ERR");
+ evalAndExpectException("store.count({})", "IDBDatabaseException.DATA_ERR");
+ evalAndExpectException("store.count(/regex/)", "IDBDatabaseException.DATA_ERR");
+
+ var tests = [
+ { key: 0, expected: 1 },
+ { key: 100, expected: 0 },
+ { key: null, expected: 100 }
+ ];
+
+ function nextTest() {
+ debug("");
+ evalAndLog("test = " + JSON.stringify(tests.shift()));
+ request = evalAndLog("request = store.count(test.key)");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function() {
+ shouldBeTrue("typeof request.result == 'number'");
+ shouldBe("request.result", String(test.expected));
+ if (tests.length) {
+ nextTest();
+ }
+ // otherwise let the transaction complete
+ };
+ }
+
+ nextTest();
+}
+
test();
</script>
Modified: trunk/Source/WebCore/ChangeLog (108851 => 108852)
--- trunk/Source/WebCore/ChangeLog 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/ChangeLog 2012-02-24 22:56:00 UTC (rev 108852)
@@ -1,3 +1,29 @@
+2012-02-24 Joshua Bell <[email protected]>
+
+ IndexedDB: IDBObjectStore.count() and IDBIndex.count() should accept key argument
+ https://bugs.webkit.org/show_bug.cgi?id=79422
+
+ Reviewed by Tony Chang.
+
+ Tests: storage/indexeddb/index-count.html
+ storage/indexeddb/objectstore-count.html
+
+ * storage/IDBIndex.cpp:
+ (WebCore::IDBIndex::count):
+ (WebCore):
+ * storage/IDBIndex.h:
+ (WebCore::IDBIndex::count):
+ (IDBIndex):
+ * storage/IDBIndex.idl:
+ * storage/IDBObjectStore.cpp:
+ (WebCore::IDBObjectStore::deleteFunction):
+ (WebCore::IDBObjectStore::count):
+ (WebCore):
+ * storage/IDBObjectStore.h:
+ (WebCore::IDBObjectStore::count):
+ (IDBObjectStore):
+ * storage/IDBObjectStore.idl:
+
2012-02-24 Adam Barth <[email protected]>
Move mediastream into Modules/mediastream
Modified: trunk/Source/WebCore/storage/IDBIndex.cpp (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBIndex.cpp 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBIndex.cpp 2012-02-24 22:56:00 UTC (rev 108852)
@@ -87,6 +87,15 @@
return request;
}
+PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec)
+{
+ IDB_TRACE("IDBIndex::count");
+ RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(key, ec);
+ if (ec)
+ return 0;
+ return count(context, keyRange.release(), ec);
+}
+
PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, unsigned short direction, ExceptionCode& ec)
{
IDB_TRACE("IDBIndex::openKeyCursor");
Modified: trunk/Source/WebCore/storage/IDBIndex.h (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBIndex.h 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBIndex.h 2012-02-24 22:56:00 UTC (rev 108852)
@@ -58,8 +58,9 @@
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, 0, ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::NEXT, ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, unsigned short direction, ExceptionCode&);
- PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, 0, ec); }
+ PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
+ PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openKeyCursor(context, 0, ec); }
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openKeyCursor(context, keyRange, IDBCursor::NEXT, ec); }
Modified: trunk/Source/WebCore/storage/IDBIndex.idl (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBIndex.idl 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBIndex.idl 2012-02-24 22:56:00 UTC (rev 108852)
@@ -44,6 +44,8 @@
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBRequest count(in [Optional] IDBKeyRange range)
raises (IDBDatabaseException);
+ [CallWith=ScriptExecutionContext] IDBRequest count(in IDBKey key)
+ raises (IDBDatabaseException);
};
}
Modified: trunk/Source/WebCore/storage/IDBObjectStore.cpp (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBObjectStore.cpp 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBObjectStore.cpp 2012-02-24 22:56:00 UTC (rev 108852)
@@ -131,6 +131,7 @@
PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec)
{
+ IDB_TRACE("IDBObjectStore::delete");
if (!keyRange) {
ec = IDBDatabaseException::DATA_ERR;
return 0;
@@ -257,6 +258,15 @@
return request.release();
}
+PassRefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec)
+{
+ IDB_TRACE("IDBObjectStore::count");
+ RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(key, ec);
+ if (ec)
+ return 0;
+ return count(context, keyRange.release(), ec);
+}
+
void IDBObjectStore::transactionFinished()
{
ASSERT(m_transaction->finished());
Modified: trunk/Source/WebCore/storage/IDBObjectStore.h (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBObjectStore.h 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBObjectStore.h 2012-02-24 22:56:00 UTC (rev 108852)
@@ -79,8 +79,9 @@
void deleteIndex(const String& name, ExceptionCode&);
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, unsigned short direction, ExceptionCode&);
- PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, 0, ec); }
+ PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
+ PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
void transactionFinished();
Modified: trunk/Source/WebCore/storage/IDBObjectStore.idl (108851 => 108852)
--- trunk/Source/WebCore/storage/IDBObjectStore.idl 2012-02-24 22:54:58 UTC (rev 108851)
+++ trunk/Source/WebCore/storage/IDBObjectStore.idl 2012-02-24 22:56:00 UTC (rev 108852)
@@ -55,5 +55,7 @@
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBRequest count(in [Optional] IDBKeyRange range)
raises (IDBDatabaseException);
+ [CallWith=ScriptExecutionContext] IDBRequest count(in IDBKey key)
+ raises (IDBDatabaseException);
};
}