Diff
Modified: trunk/LayoutTests/ChangeLog (109304 => 109305)
--- trunk/LayoutTests/ChangeLog 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/LayoutTests/ChangeLog 2012-03-01 05:22:57 UTC (rev 109305)
@@ -1,3 +1,13 @@
+2012-02-29 Joshua Bell <[email protected]>
+
+ IndexedDB: IDBDatabase.objectStoreNames and IDObjectStore.indexNames results should be sorted
+ https://bugs.webkit.org/show_bug.cgi?id=79950
+
+ Reviewed by Tony Chang.
+
+ * storage/indexeddb/list-ordering-expected.txt: Added.
+ * storage/indexeddb/list-ordering.html: Added.
+
2012-02-29 Kentaro Hara <[email protected]>
Unreviewed, gardening.
Added: trunk/LayoutTests/storage/indexeddb/list-ordering-expected.txt (0 => 109305)
--- trunk/LayoutTests/storage/indexeddb/list-ordering-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/list-ordering-expected.txt 2012-03-01 05:22:57 UTC (rev 109305)
@@ -0,0 +1,65 @@
+
+Test string list ordering in IndexedDB.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB
+PASS indexedDB != null is true
+check that the expected order is the canonical JS sort order:
+sorted_order = expected_order.slice(); sorted_order.sort()
+PASS areArraysEqual(sorted_order, expected_order) is true
+
+testStoresAndIndexes():
+indexedDB.deleteDatabase('list-ordering')
+indexedDB.open('list-ordering')
+db = request.result
+PASS db.version is ""
+db.setVersion('1')
+
+Object stores:
+db.createObjectStore("𝄞")
+db.createObjectStore("�")
+db.createObjectStore("Ā")
+db.createObjectStore("က")
+db.createObjectStore("á")
+db.createObjectStore("ÿ")
+db.createObjectStore("Á")
+db.createObjectStore("à")
+db.createObjectStore("")
+db.createObjectStore("À")
+db.createObjectStore("a")
+db.createObjectStore("b")
+db.createObjectStore("A")
+db.createObjectStore("B")
+db.createObjectStore("0")
+db.createObjectStore("1")
+db.createObjectStore("\u0000")
+db.createObjectStore("")
+PASS areArraysEqual(db.objectStoreNames, expected_order) is true
+
+Indexes:
+store = db.createObjectStore('store')
+store.createIndex("𝄞", 'keyPath')
+store.createIndex("�", 'keyPath')
+store.createIndex("Ā", 'keyPath')
+store.createIndex("က", 'keyPath')
+store.createIndex("á", 'keyPath')
+store.createIndex("ÿ", 'keyPath')
+store.createIndex("Á", 'keyPath')
+store.createIndex("à", 'keyPath')
+store.createIndex("", 'keyPath')
+store.createIndex("À", 'keyPath')
+store.createIndex("a", 'keyPath')
+store.createIndex("b", 'keyPath')
+store.createIndex("A", 'keyPath')
+store.createIndex("B", 'keyPath')
+store.createIndex("0", 'keyPath')
+store.createIndex("1", 'keyPath')
+store.createIndex("\u0000", 'keyPath')
+store.createIndex("", 'keyPath')
+PASS areArraysEqual(store.indexNames, expected_order) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/list-ordering.html (0 => 109305)
--- trunk/LayoutTests/storage/indexeddb/list-ordering.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/list-ordering.html 2012-03-01 05:22:57 UTC (rev 109305)
@@ -0,0 +1,100 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" id="fileInput" multiple></input>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test string list ordering in IndexedDB.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+var expected_order = [
+ "",
+ "\x00", // 'NULL' (U+0000)
+ "0",
+ "1",
+ "A",
+ "B",
+ "a",
+ "b",
+ "\x7F", // 'DELETE' (U+007F)
+ "\xC0", // 'LATIN CAPITAL LETTER A WITH GRAVE' (U+00C0)
+ "\xC1", // 'LATIN CAPITAL LETTER A WITH ACUTE' (U+00C1)
+ "\xE0", // 'LATIN SMALL LETTER A WITH GRAVE' (U+00E0)
+ "\xE1", // 'LATIN SMALL LETTER A WITH ACUTE' (U+00E1)
+ "\xFF", // 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF)
+ "\u0100", // 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100)
+ "\u1000", // 'MYANMAR LETTER KA' (U+1000)
+ "\uD834\uDD1E", // 'MUSICAL SYMBOL G-CLEF' (U+1D11E), UTF-16 surrogate pairs
+ "\uFFFD" // 'REPLACEMENT CHARACTER' (U+FFFD)
+];
+var i, tmp, permuted_order = expected_order.slice(); permuted_order.reverse();
+for (i = 0; i < permuted_order.length - 2; i += 2) {
+ tmp = permuted_order[i];
+ permuted_order[i] = permuted_order[i + 1];
+ permuted_order[i + 1] = tmp;
+}
+
+function test()
+{
+ evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB");
+ shouldBeTrue("indexedDB != null");
+
+ debug("check that the expected order is the canonical JS sort order:");
+ evalAndLog("sorted_order = expected_order.slice(); sorted_order.sort()");
+ shouldBeTrue("areArraysEqual(sorted_order, expected_order)");
+ testStoresAndIndexes();
+}
+
+
+
+function testStoresAndIndexes()
+{
+ debug("");
+ debug("testStoresAndIndexes():");
+ request = evalAndLog("indexedDB.deleteDatabase('list-ordering')");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function(e) {
+ request = evalAndLog("indexedDB.open('list-ordering')");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function(e) {
+ evalAndLog("db = request.result");
+ shouldBeEqualToString("db.version", "");
+ request = evalAndLog("db.setVersion('1')");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function(e) {
+ trans = request.result;
+
+ debug("");
+ debug("Object stores:");
+ permuted_order.forEach(function (name) {
+ evalAndLog("db.createObjectStore(" + JSON.stringify(name) +")");
+ });
+
+ shouldBeTrue("areArraysEqual(db.objectStoreNames, expected_order)");
+
+ debug("");
+ debug("Indexes:");
+ store = evalAndLog("store = db.createObjectStore('store')");
+ permuted_order.forEach(function (name) {
+ evalAndLog("store.createIndex(" + JSON.stringify(name) +", 'keyPath')");
+ });
+
+ shouldBeTrue("areArraysEqual(store.indexNames, expected_order)");
+
+ trans._oncomplete_ = done;
+ };
+ };
+ };
+}
+
+test();
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (109304 => 109305)
--- trunk/Source/WebCore/ChangeLog 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/Source/WebCore/ChangeLog 2012-03-01 05:22:57 UTC (rev 109305)
@@ -1,3 +1,22 @@
+2012-02-29 Joshua Bell <[email protected]>
+
+ IndexedDB: IDBDatabase.objectStoreNames and IDObjectStore.indexNames results should be sorted
+ https://bugs.webkit.org/show_bug.cgi?id=79950
+
+ Reviewed by Tony Chang.
+
+ Test: storage/indexeddb/list-ordering.html
+
+ * dom/DOMStringList.cpp: Added sort method, not exposed via IDL.
+ (WebCore::DOMStringList::sort):
+ (WebCore):
+ * dom/DOMStringList.h:
+ (DOMStringList):
+ * storage/IDBDatabaseBackendImpl.cpp:
+ (WebCore::IDBDatabaseBackendImpl::objectStoreNames):
+ * storage/IDBObjectStoreBackendImpl.cpp:
+ (WebCore::IDBObjectStoreBackendImpl::indexNames):
+
2012-02-29 W. James MacLean <[email protected]>
[chromium] Estimate pixel count for frame rate control
Modified: trunk/Source/WebCore/dom/DOMStringList.cpp (109304 => 109305)
--- trunk/Source/WebCore/dom/DOMStringList.cpp 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/Source/WebCore/dom/DOMStringList.cpp 2012-03-01 05:22:57 UTC (rev 109305)
@@ -48,4 +48,9 @@
return false;
}
+void DOMStringList::sort()
+{
+ std::sort(m_strings.begin(), m_strings.end(), WTF::codePointCompareLessThan);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/DOMStringList.h (109304 => 109305)
--- trunk/Source/WebCore/dom/DOMStringList.h 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/Source/WebCore/dom/DOMStringList.h 2012-03-01 05:22:57 UTC (rev 109305)
@@ -45,6 +45,7 @@
bool isEmpty() const { return m_strings.isEmpty(); }
void clear() { m_strings.clear(); }
void append(const String& string) { m_strings.append(string); }
+ void sort();
// Implements the IDL.
size_t length() const { return m_strings.size(); }
Modified: trunk/Source/WebCore/storage/IDBDatabaseBackendImpl.cpp (109304 => 109305)
--- trunk/Source/WebCore/storage/IDBDatabaseBackendImpl.cpp 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/Source/WebCore/storage/IDBDatabaseBackendImpl.cpp 2012-03-01 05:22:57 UTC (rev 109305)
@@ -133,6 +133,7 @@
RefPtr<DOMStringList> objectStoreNames = DOMStringList::create();
for (ObjectStoreMap::const_iterator it = m_objectStores.begin(); it != m_objectStores.end(); ++it)
objectStoreNames->append(it->first);
+ objectStoreNames->sort();
return objectStoreNames.release();
}
Modified: trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp (109304 => 109305)
--- trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2012-03-01 04:33:03 UTC (rev 109304)
+++ trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2012-03-01 05:22:57 UTC (rev 109305)
@@ -79,6 +79,7 @@
RefPtr<DOMStringList> indexNames = DOMStringList::create();
for (IndexMap::const_iterator it = m_indexes.begin(); it != m_indexes.end(); ++it)
indexNames->append(it->first);
+ indexNames->sort();
return indexNames.release();
}