Diff
Modified: trunk/LayoutTests/ChangeLog (192846 => 192847)
--- trunk/LayoutTests/ChangeLog 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/ChangeLog 2015-12-01 01:28:15 UTC (rev 192847)
@@ -1,3 +1,15 @@
+2015-11-30 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: "prevunique" cursors should point at the lowest primary key that matches, not the highest.
+ https://bugs.webkit.org/show_bug.cgi?id=151675.
+
+ Reviewed by Darin Adler.
+
+ * platform/mac-wk1/TestExpectations:
+ * storage/indexeddb/modern/index-cursor-1-expected.txt:
+ * storage/indexeddb/modern/index-cursor-2-expected.txt:
+ * storage/indexeddb/modern/index-cursor-3-expected.txt:
+
2015-11-30 Jiewen Tan <jiewen_...@apple.com>
Null dereference loading Blink layout test http/tests/misc/detach-during-notifyDone.html
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (192846 => 192847)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2015-12-01 01:28:15 UTC (rev 192847)
@@ -89,6 +89,7 @@
storage/indexeddb/mozilla/delete-result.html [ Pass ]
storage/indexeddb/mozilla/event-source.html [ Pass ]
storage/indexeddb/mozilla/global-data.html [ Pass ]
+storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Pass ]
storage/indexeddb/mozilla/key-requirements-delete-null-key.html [ Pass ]
storage/indexeddb/mozilla/key-requirements-inline-and-passed.html [ Pass ]
storage/indexeddb/mozilla/key-requirements-put-no-key.html [ Pass ]
Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt (192846 => 192847)
--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt 2015-12-01 01:28:15 UTC (rev 192847)
@@ -356,25 +356,25 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: D
-Cursor primary key is: 12
+Cursor primary key is: 10
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: C
-Cursor primary key is: 9
+Cursor primary key is: 7
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: B
-Cursor primary key is: 6
+Cursor primary key is: 4
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: A
-Cursor primary key is: 3
+Cursor primary key is: 1
Cursor value is: [object Object]
Starting a new cursor: testCursorDirection(index2, 'prevunique')
@@ -382,25 +382,25 @@
Cursor direction is: prevunique
Cursor source is: TestIndex2
Cursor key is: d
-Cursor primary key is: 12
+Cursor primary key is: 10
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex2
Cursor key is: c
-Cursor primary key is: 9
+Cursor primary key is: 7
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex2
Cursor key is: b
-Cursor primary key is: 6
+Cursor primary key is: 4
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex2
Cursor key is: a
-Cursor primary key is: 3
+Cursor primary key is: 1
Cursor value is: [object Object]
Done
Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt (192846 => 192847)
--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt 2015-12-01 01:28:15 UTC (rev 192847)
@@ -55,7 +55,7 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: C
-Cursor primary key is: 9
+Cursor primary key is: 7
Cursor value is: [object Object]
Starting a new cursor: testCursorDirection('next', IDBKeyRange.bound('B', 'C'))
@@ -153,13 +153,13 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: C
-Cursor primary key is: 9
+Cursor primary key is: 7
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: B
-Cursor primary key is: 6
+Cursor primary key is: 4
Cursor value is: [object Object]
Starting a new cursor: testCursorDirection('next', IDBKeyRange.upperBound('B'))
@@ -257,13 +257,13 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: B
-Cursor primary key is: 6
+Cursor primary key is: 4
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: A
-Cursor primary key is: 3
+Cursor primary key is: 1
Cursor value is: [object Object]
Starting a new cursor: testCursorDirection('next', IDBKeyRange.lowerBound('C'))
@@ -361,13 +361,13 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: D
-Cursor primary key is: 12
+Cursor primary key is: 10
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: C
-Cursor primary key is: 9
+Cursor primary key is: 7
Cursor value is: [object Object]
Starting a new cursor: testCursorDirection('next', IDBKeyRange.only('B'))
@@ -423,7 +423,7 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: B
-Cursor primary key is: 6
+Cursor primary key is: 4
Cursor value is: [object Object]
Done
Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt (192846 => 192847)
--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt 2015-12-01 01:28:15 UTC (rev 192847)
@@ -240,35 +240,26 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: I
-Cursor primary key is: 18
+Cursor primary key is: 17
Cursor value is: [object Object]
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: H
-Cursor primary key is: 16
+Cursor primary key is: 15
Cursor value is: [object Object]
-Deleted key 16 from object store
Deleted key 15 from object store
Deleted key 14 from object store
-Success opening or iterating cursor
-Cursor direction is: prevunique
-Cursor source is: TestIndex1
-Cursor key is: G
-Cursor primary key is: 13
-Cursor value is: [object Object]
Deleted key 13 from object store
-Deleted key 12 from object store
-Deleted key 11 from object store
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
-Cursor key is: E
-Cursor primary key is: 10
+Cursor key is: F
+Cursor primary key is: 11
Cursor value is: [object Object]
+Deleted key 11 from object store
Deleted key 10 from object store
Deleted key 9 from object store
-Deleted key 8 from object store
Success opening or iterating cursor
Cursor direction is: prevunique
Cursor source is: TestIndex1
@@ -282,17 +273,10 @@
Cursor direction is: prevunique
Cursor source is: TestIndex1
Cursor key is: B
-Cursor primary key is: 4
+Cursor primary key is: 3
Cursor value is: [object Object]
-Deleted key 4 from object store
Deleted key 3 from object store
Deleted key 2 from object store
-Success opening or iterating cursor
-Cursor direction is: prevunique
-Cursor source is: TestIndex1
-Cursor key is: A
-Cursor primary key is: 1
-Cursor value is: [object Object]
Deleted key 1 from object store
Success opening or iterating cursor
Done
Modified: trunk/Source/WebCore/ChangeLog (192846 => 192847)
--- trunk/Source/WebCore/ChangeLog 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/ChangeLog 2015-12-01 01:28:15 UTC (rev 192847)
@@ -1,3 +1,33 @@
+2015-11-30 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: "prevunique" cursors should point at the lowest primary key that matches, not the highest.
+ https://bugs.webkit.org/show_bug.cgi?id=151675.
+
+ Reviewed by Darin Adler.
+
+ No new tests (Covered by at least one failing test that now passes, and updates to previously incorrect tests).
+
+ * Modules/indexeddb/server/IndexValueEntry.cpp:
+ (WebCore::IDBServer::IndexValueEntry::reverseBegin): If CursorDuplicity is NoDuplicates, start at the lowest
+ entry instead of the highest.
+ (WebCore::IDBServer::IndexValueEntry::reverseFind):
+ * Modules/indexeddb/server/IndexValueEntry.h:
+
+ * Modules/indexeddb/server/IndexValueStore.cpp:
+ (WebCore::IDBServer::IndexValueStore::reverseFind):
+ (WebCore::IDBServer::IndexValueStore::Iterator::Iterator):
+ (WebCore::IDBServer::IndexValueStore::Iterator::nextIndexEntry):
+ * Modules/indexeddb/server/IndexValueStore.h:
+
+ * Modules/indexeddb/server/MemoryIndexCursor.cpp:
+ (WebCore::IDBServer::MemoryIndexCursor::MemoryIndexCursor):
+ (WebCore::IDBServer::MemoryIndexCursor::iterate):
+
+ * Modules/indexeddb/shared/IDBCursorInfo.cpp:
+ (WebCore::IDBCursorInfo::duplicity):
+ (WebCore::IDBCursorInfo::isDirectionNoDuplicate): Deleted.
+ * Modules/indexeddb/shared/IDBCursorInfo.h:
+
2015-11-30 Jiewen Tan <jiewen_...@apple.com>
Null dereference loading Blink layout test http/tests/misc/detach-during-notifyDone.html
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp 2015-12-01 01:28:15 UTC (rev 192847)
@@ -28,6 +28,8 @@
#if ENABLE(INDEXED_DATABASE)
+#include "IDBCursorInfo.h"
+
namespace WebCore {
namespace IDBServer {
@@ -176,7 +178,7 @@
return { *this, m_orderedKeys->begin() };
}
-IndexValueEntry::Iterator IndexValueEntry::reverseBegin()
+IndexValueEntry::Iterator IndexValueEntry::reverseBegin(CursorDuplicity duplicity)
{
if (m_unique) {
ASSERT(m_key);
@@ -184,7 +186,13 @@
}
ASSERT(m_orderedKeys);
- return { *this, m_orderedKeys->rbegin() };
+
+ if (duplicity == CursorDuplicity::Duplicates)
+ return { *this, m_orderedKeys->rbegin() };
+
+ auto iterator = m_orderedKeys->rend();
+ --iterator;
+ return { *this, iterator };
}
IndexValueEntry::Iterator IndexValueEntry::find(const IDBKeyData& key)
@@ -202,7 +210,7 @@
return { *this, iterator };
}
-IndexValueEntry::Iterator IndexValueEntry::reverseFind(const IDBKeyData& key)
+IndexValueEntry::Iterator IndexValueEntry::reverseFind(const IDBKeyData& key, CursorDuplicity)
{
if (m_unique) {
ASSERT(m_key);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h 2015-12-01 01:28:15 UTC (rev 192847)
@@ -35,6 +35,8 @@
class ThreadSafeDataBuffer;
+enum class CursorDuplicity;
+
namespace IDBServer {
class IndexValueEntry {
@@ -77,12 +79,12 @@
};
Iterator begin();
- Iterator reverseBegin();
+ Iterator reverseBegin(CursorDuplicity);
// Finds the key, or the next higher record after the key.
Iterator find(const IDBKeyData&);
// Finds the key, or the next lowest record before the key.
- Iterator reverseFind(const IDBKeyData&);
+ Iterator reverseFind(const IDBKeyData&, CursorDuplicity);
bool unique() const { return m_unique; }
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp 2015-12-01 01:28:15 UTC (rev 192847)
@@ -231,7 +231,7 @@
return { *this, iterator, primaryIterator };
}
-IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData& key, bool open)
+IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData& key, CursorDuplicity duplicity, bool open)
{
IDBKeyRangeData range;
if (!key.isNull())
@@ -247,12 +247,12 @@
auto record = m_records.get(*iterator);
ASSERT(record);
- auto primaryIterator = record->reverseBegin();
+ auto primaryIterator = record->reverseBegin(duplicity);
ASSERT(primaryIterator.isValid());
- return { *this, iterator, primaryIterator };
+ return { *this, duplicity, iterator, primaryIterator };
}
-IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData& key, const IDBKeyData& primaryKey)
+IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData& key, const IDBKeyData& primaryKey, CursorDuplicity duplicity)
{
ASSERT(!key.isNull());
ASSERT(!primaryKey.isNull());
@@ -268,9 +268,9 @@
auto record = m_records.get(*iterator);
ASSERT(record);
- auto primaryIterator = record->reverseFind(primaryKey);
+ auto primaryIterator = record->reverseFind(primaryKey, duplicity);
if (primaryIterator.isValid())
- return { *this, iterator, primaryIterator };
+ return { *this, duplicity, iterator, primaryIterator };
// If we didn't find a primary key iterator in this entry,
// we need to move on to start of the next record.
@@ -281,10 +281,10 @@
record = m_records.get(*iterator);
ASSERT(record);
- primaryIterator = record->reverseBegin();
+ primaryIterator = record->reverseBegin(duplicity);
ASSERT(primaryIterator.isValid());
- return { *this, iterator, primaryIterator };
+ return { *this, duplicity, iterator, primaryIterator };
}
@@ -295,9 +295,10 @@
{
}
-IndexValueStore::Iterator::Iterator(IndexValueStore& store, std::set<IDBKeyData>::reverse_iterator iterator, IndexValueEntry::Iterator primaryIterator)
+IndexValueStore::Iterator::Iterator(IndexValueStore& store, CursorDuplicity duplicity, std::set<IDBKeyData>::reverse_iterator iterator, IndexValueEntry::Iterator primaryIterator)
: m_store(&store)
, m_forward(false)
+ , m_duplicity(duplicity)
, m_reverseIterator(iterator)
, m_primaryKeyIterator(primaryIterator)
{
@@ -330,7 +331,7 @@
auto* entry = m_store->m_records.get(*m_reverseIterator);
ASSERT(entry);
- m_primaryKeyIterator = entry->reverseBegin();
+ m_primaryKeyIterator = entry->reverseBegin(m_duplicity);
ASSERT(m_primaryKeyIterator.isValid());
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h 2015-12-01 01:28:15 UTC (rev 192847)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "IDBCursorInfo.h"
#include "IDBKeyData.h"
#include "IndexValueEntry.h"
#include <set>
@@ -67,7 +68,7 @@
}
Iterator(IndexValueStore&, std::set<IDBKeyData>::iterator, IndexValueEntry::Iterator);
- Iterator(IndexValueStore&, std::set<IDBKeyData>::reverse_iterator, IndexValueEntry::Iterator);
+ Iterator(IndexValueStore&, CursorDuplicity, std::set<IDBKeyData>::reverse_iterator, IndexValueEntry::Iterator);
void invalidate();
bool isValid();
@@ -82,6 +83,7 @@
private:
IndexValueStore* m_store { nullptr };
bool m_forward { true };
+ CursorDuplicity m_duplicity { CursorDuplicity::Duplicates };
std::set<IDBKeyData>::iterator m_forwardIterator;
std::set<IDBKeyData>::reverse_iterator m_reverseIterator;
@@ -90,11 +92,11 @@
// Returns an iterator pointing to the first primaryKey record in the requested key, or the next key if it doesn't exist.
Iterator find(const IDBKeyData&, bool open = false);
- Iterator reverseFind(const IDBKeyData&, bool open = false);
+ Iterator reverseFind(const IDBKeyData&, CursorDuplicity, bool open = false);
// Returns an iterator pointing to the key/primaryKey record, or the next one after it if it doesn't exist.
Iterator find(const IDBKeyData&, const IDBKeyData& primaryKey);
- Iterator reverseFind(const IDBKeyData&, const IDBKeyData& primaryKey);
+ Iterator reverseFind(const IDBKeyData&, const IDBKeyData& primaryKey, CursorDuplicity);
private:
std::set<IDBKeyData>::iterator lowestIteratorInRange(const IDBKeyRangeData&) const;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp 2015-12-01 01:28:15 UTC (rev 192847)
@@ -50,7 +50,7 @@
if (m_info.isDirectionForward())
iterator = valueStore->find(m_info.range().lowerKey, m_info.range().lowerOpen);
else
- iterator = valueStore->reverseFind(m_info.range().upperKey, m_info.range().upperOpen);
+ iterator = valueStore->reverseFind(m_info.range().upperKey, m_info.duplicity(), m_info.range().upperOpen);
if (iterator.isValid()) {
m_currentKey = iterator.key();
@@ -90,7 +90,7 @@
if (m_info.isDirectionForward())
m_currentIterator = valueStore->find(m_currentKey);
else
- m_currentIterator = valueStore->reverseFind(m_currentKey);
+ m_currentIterator = valueStore->reverseFind(m_currentKey, m_info.duplicity());
if (!m_currentIterator.isValid()) {
m_currentKey = { };
@@ -130,10 +130,10 @@
m_currentIterator = valueStore->find(m_currentKey, true);
break;
case IndexedDB::CursorDirection::Prev:
- m_currentIterator = valueStore->reverseFind(m_currentKey, m_currentPrimaryKey);
+ m_currentIterator = valueStore->reverseFind(m_currentKey, m_currentPrimaryKey, m_info.duplicity());
break;
case IndexedDB::CursorDirection::PrevNoDuplicate:
- m_currentIterator = valueStore->reverseFind(m_currentKey, true);
+ m_currentIterator = valueStore->reverseFind(m_currentKey, m_info.duplicity(), true);
break;
}
@@ -155,7 +155,7 @@
ASSERT(m_currentIterator.isValid());
while (count) {
- if (m_info.isDirectionNoDuplicate())
+ if (m_info.duplicity() == CursorDuplicity::NoDuplicates)
m_currentIterator.nextIndexEntry();
else
++m_currentIterator;
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp 2015-12-01 01:28:15 UTC (rev 192847)
@@ -84,9 +84,9 @@
return m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::NextNoDuplicate;
}
-bool IDBCursorInfo::isDirectionNoDuplicate() const
+CursorDuplicity IDBCursorInfo::duplicity() const
{
- return m_direction == IndexedDB::CursorDirection::NextNoDuplicate || m_direction == IndexedDB::CursorDirection::PrevNoDuplicate;
+ return m_direction == IndexedDB::CursorDirection::NextNoDuplicate || m_direction == IndexedDB::CursorDirection::PrevNoDuplicate ? CursorDuplicity::NoDuplicates : CursorDuplicity::Duplicates;
}
IDBCursorInfo IDBCursorInfo::isolatedCopy() const
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h (192846 => 192847)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h 2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h 2015-12-01 01:28:15 UTC (rev 192847)
@@ -45,6 +45,11 @@
struct IDBKeyRangeData;
+enum class CursorDuplicity {
+ Duplicates,
+ NoDuplicates,
+};
+
class IDBCursorInfo {
public:
static IDBCursorInfo objectStoreCursor(IDBClient::IDBTransaction&, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IndexedDB::CursorDirection);
@@ -60,7 +65,7 @@
const IDBKeyRangeData& range() const { return m_range; }
bool isDirectionForward() const;
- bool isDirectionNoDuplicate() const;
+ CursorDuplicity duplicity() const;
IDBCursorInfo isolatedCopy() const;