Title: [192518] trunk
Revision
192518
Author
[email protected]
Date
2015-11-17 11:41:26 -0800 (Tue, 17 Nov 2015)

Log Message

Modern IDB: Support IDBObjectStore.indexNames.
https://bugs.webkit.org/show_bug.cgi?id=151341

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (Covered by existing storage/indexeddb/modern/objectstore-attributes.html).

* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::indexNames):
* Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:
(WebCore::IDBObjectStoreInfo::indexNames):
* Modules/indexeddb/shared/IDBObjectStoreInfo.h:

LayoutTests:

* storage/indexeddb/modern/objectstore-attributes-expected.txt:
* storage/indexeddb/modern/objectstore-attributes.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192517 => 192518)


--- trunk/LayoutTests/ChangeLog	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/LayoutTests/ChangeLog	2015-11-17 19:41:26 UTC (rev 192518)
@@ -1,3 +1,13 @@
+2015-11-17  Brady Eidson  <[email protected]>
+
+        Modern IDB: Support IDBObjectStore.indexNames.
+        https://bugs.webkit.org/show_bug.cgi?id=151341
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/objectstore-attributes-expected.txt:
+        * storage/indexeddb/modern/objectstore-attributes.html:
+
 2015-11-17  Wenson Hsieh  <[email protected]>
 
         Unreviewed, skip crashing mediastream tests

Modified: trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt (192517 => 192518)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt	2015-11-17 19:41:26 UTC (rev 192518)
@@ -1,17 +1,30 @@
-ALERT: First upgrade needed: Old version - 0 New version - 1
-ALERT: [object IDBTransaction] - versionchange
-ALERT: [object IDBDatabase]
-ALERT: TestObjectStore1
-ALERT: TestObjectStore2
-ALERT: true
-ALERT: false
-ALERT: foo
-ALERT: null
-ALERT: [object IDBTransaction]
-ALERT: [object IDBTransaction]
-ALERT: true
-ALERT: true
-ALERT: true
-ALERT: First version change transaction completed
-ALERT: Done
 This test exercises the readonly attributes on an IDBObjectStore.
+First upgrade needed: Old version - 0 New version - 1
+[object IDBTransaction] - versionchange
+[object IDBDatabase]
+TestObjectStore1
+TestObjectStore2
+true
+false
+foo
+null
+[object IDBTransaction]
+[object IDBTransaction]
+true
+true
+true
+Object store has indexes:
+Bar index
+Foo index
+After adding another, object store now has indexes:
+Bar index
+Baz index
+Foo index
+First version change transaction completed
+In a new transaction, object store has indexes:
+Bar index
+Baz index
+Foo index
+readonly transaction complete
+Done
+

Modified: trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes.html (192517 => 192518)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes.html	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-attributes.html	2015-11-17 19:41:26 UTC (rev 192518)
@@ -1,4 +1,5 @@
-This test exercises the readonly attributes on an IDBObjectStore.
+This test exercises the readonly attributes on an IDBObjectStore.<br>
+<div id="logger"></div>
 <script>
 
 if (window.testRunner) {
@@ -8,51 +9,99 @@
 
 var request = window.indexedDB.open("ObjectStoreAttributesTestDatabase");
 
+function log(message)
+{
+    document.getElementById("logger").innerHTML += message + "<br>";
+}
+
 function done()
 {
-    alert("Done");
+    log("Done");
     if (window.testRunner)
         testRunner.notifyDone();
 }
 
+var database;
+
 request._onupgradeneeded_ = function(event)
 {
-    alert("First upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+    log("First upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
     
     var tx = request.transaction;
-    var db = event.target.result;
+    database = event.target.result;
 
-    alert(tx + " - " + tx.mode);
-    alert(db);
+    log(tx + " - " + tx.mode);
+    log(database);
 
-    var os1 = db.createObjectStore('TestObjectStore1', { autoIncrement: true , keyPath: "foo" });
-    var os2 = db.createObjectStore('TestObjectStore2', { autoIncrement: false });
+    var os1 = database.createObjectStore('TestObjectStore1', { autoIncrement: true , keyPath: "foo" });
+    var os2 = database.createObjectStore('TestObjectStore2', { autoIncrement: false });
 
-    alert(os1.name);
-    alert(os2.name);
-    alert(os1.autoIncrement);
-    alert(os2.autoIncrement);
-    alert(os1.keyPath);
-    alert(os2.keyPath);
-    alert(os1.transaction);
-    alert(os2.transaction);
-    alert(os1.transaction == tx);
-    alert(os2.transaction == tx);
-    alert(os1.transaction == os2.transaction);
+    log(os1.name);
+    log(os2.name);
+    log(os1.autoIncrement);
+    log(os2.autoIncrement);
+    log(os1.keyPath);
+    log(os2.keyPath);
+    log(os1.transaction);
+    log(os2.transaction);
+    log(os1.transaction == tx);
+    log(os2.transaction == tx);
+    log(os1.transaction == os2.transaction);
     
+    os2.createIndex("Foo index", "foo");
+    os2.createIndex("Bar index", "bar");
+    
+    var names = os2.indexNames;
+    log("Object store has indexes:")
+    for (var i = 0; i < names.length; ++i)
+        log(names[i]);
+    
+    os2.createIndex("Baz index", "baz");
+    log("After adding another, object store now has indexes:");
+    names = os2.indexNames;
+    for (var i = 0; i < names.length; ++i)
+        log(names[i]);
+    
     tx._onabort_ = function(event) {
-        alert("First version change transaction unexpected abort");
+        log("First version change transaction unexpected abort");
         done();
     }
 
     tx._oncomplete_ = function(event) {
-        alert("First version change transaction completed");
-        done();
+        log("First version change transaction completed");
+        continueTest();
     }
 
     tx._onerror_ = function(event) {
-        alert("First version change transaction unexpected error - " + event);
+        log("First version change transaction unexpected error - " + event);
         done();
     }
 }
+
+function continueTest()
+{
+    var transaction = database.transaction("TestObjectStore2", "readonly");
+    var objectStore = transaction.objectStore("TestObjectStore2");
+    
+    log("In a new transaction, object store has indexes:");
+    var names = objectStore.indexNames;
+    for (var i = 0; i < names.length; ++i)
+        log(names[i]);
+
+    transaction._onabort_ = function(event) {
+        log("readonly transaction unexpected abort" + event);
+        done();
+    }
+
+    transaction._oncomplete_ = function(event) {
+        log("readonly transaction complete");
+        done();
+    }
+
+    transaction._onerror_ = function(event) {
+        log("readonly transaction unexpected error" + event);
+        done();
+    }
+}
+
 </script>

Modified: trunk/Source/WebCore/ChangeLog (192517 => 192518)


--- trunk/Source/WebCore/ChangeLog	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/Source/WebCore/ChangeLog	2015-11-17 19:41:26 UTC (rev 192518)
@@ -1,3 +1,18 @@
+2015-11-17  Brady Eidson  <[email protected]>
+
+        Modern IDB: Support IDBObjectStore.indexNames.
+        https://bugs.webkit.org/show_bug.cgi?id=151341
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Covered by existing storage/indexeddb/modern/objectstore-attributes.html).
+
+        * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+        (WebCore::IDBClient::IDBObjectStore::indexNames):
+        * Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:
+        (WebCore::IDBObjectStoreInfo::indexNames):
+        * Modules/indexeddb/shared/IDBObjectStoreInfo.h:
+
 2015-11-17  Sergio Villar Senin  <[email protected]>
 
         ASSERTION FAILED: contentSize >= 0 in WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (192517 => 192518)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp	2015-11-17 19:41:26 UTC (rev 192518)
@@ -77,7 +77,12 @@
 
 RefPtr<DOMStringList> IDBObjectStore::indexNames() const
 {
-    RELEASE_ASSERT_NOT_REACHED();
+    RefPtr<DOMStringList> indexNames = DOMStringList::create();
+    for (auto& name : m_info.indexNames())
+        indexNames->append(name);
+    indexNames->sort();
+
+    return indexNames;
 }
 
 RefPtr<WebCore::IDBTransaction> IDBObjectStore::transaction()

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.cpp (192517 => 192518)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.cpp	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.cpp	2015-11-17 19:41:26 UTC (rev 192518)
@@ -89,6 +89,16 @@
     return result;
 }
 
+Vector<String> IDBObjectStoreInfo::indexNames() const
+{
+    Vector<String> names;
+    names.reserveCapacity(m_indexMap.size());
+    for (auto& index : m_indexMap.values())
+        names.uncheckedAppend(index.name());
+
+    return names;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h (192517 => 192518)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h	2015-11-17 19:30:14 UTC (rev 192517)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h	2015-11-17 19:41:26 UTC (rev 192518)
@@ -54,6 +54,8 @@
     bool hasIndex(const String& name) const;
     IDBIndexInfo* infoForExistingIndex(const String& name);
 
+    Vector<String> indexNames() const;
+
 private:
     uint64_t m_identifier { 0 };
     String m_name;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to