Modern IDB: Implement most readonly attributes of IDBObjectStore.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2015 17:29:41 +0000 (17:29 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2015 17:29:41 +0000 (17:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150617

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/indexeddb/modern/objectstore-attributes.html

* Modules/indexeddb/IDBObjectStore.h:

* Modules/indexeddb/client/IDBAnyImpl.cpp:
(WebCore::IDBClient::IDBAny::IDBAny):
* Modules/indexeddb/client/IDBAnyImpl.h:
(WebCore::IDBClient::IDBAny::create):

* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::name):
(WebCore::IDBClient::IDBObjectStore::keyPathAny):
(WebCore::IDBClient::IDBObjectStore::keyPath):
(WebCore::IDBClient::IDBObjectStore::transaction):
(WebCore::IDBClient::IDBObjectStore::id): Deleted.
* Modules/indexeddb/client/IDBObjectStoreImpl.h:

* Modules/indexeddb/legacy/LegacyObjectStore.h:
(WebCore::LegacyObjectStore::transaction):

LayoutTests:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191672 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/objectstore-attributes.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.h
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h
Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h

index fd79bbdd67210f5f2946124afd5256c551d2ffcd..3e2242714cd47d26d96c44a60258ce82ebf39487 100644 (file)
@@ -1,3 +1,13 @@
+2015-10-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Implement most readonly attributes of IDBObjectStore.
+        https://bugs.webkit.org/show_bug.cgi?id=150617
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/objectstore-attributes-expected.txt: Added.
+        * storage/indexeddb/modern/objectstore-attributes.html: Added.
+
 2015-10-28  Hunseop Jeong  <hs85.jeong@samsung.com>
 
         Unreviewed. EFL gardening: rebaseline more tests after r191623.
diff --git a/LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt b/LayoutTests/storage/indexeddb/modern/objectstore-attributes-expected.txt
new file mode 100644 (file)
index 0000000..b6e2152
--- /dev/null
@@ -0,0 +1,17 @@
+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.
diff --git a/LayoutTests/storage/indexeddb/modern/objectstore-attributes.html b/LayoutTests/storage/indexeddb/modern/objectstore-attributes.html
new file mode 100644 (file)
index 0000000..b5076c0
--- /dev/null
@@ -0,0 +1,58 @@
+This test exercises the readonly attributes on an IDBObjectStore.
+<script>
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+
+var request = window.indexedDB.open("ObjectStoreAttributesTestDatabase");
+
+function done()
+{
+    alert("Done");
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+request.onupgradeneeded = function(event)
+{
+    alert("First upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+    
+    var tx = request.transaction;
+    var db = event.target.result;
+
+    alert(tx + " - " + tx.mode);
+    alert(db);
+
+    var os1 = db.createObjectStore('TestObjectStore1', { autoIncrement: true , keyPath: "foo" });
+    var os2 = db.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);
+    
+    tx.onabort = function(event) {
+        alert("First version change transaction unexpected abort");
+        done();
+    }
+
+    tx.oncomplete = function(event) {
+        alert("First version change transaction completed");
+        done();
+    }
+
+    tx.onerror = function(event) {
+        alert("First version change transaction unexpected error - " + event);
+        done();
+    }
+}
+</script>
index 97d9e4401eb9bd1800532e9b17537233d3ab3211..1d9f484a65d8e2aaaf5d3964f63b79e3cefffcda 100644 (file)
@@ -1,3 +1,30 @@
+2015-10-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Implement most readonly attributes of IDBObjectStore.
+        https://bugs.webkit.org/show_bug.cgi?id=150617
+
+        Reviewed by Alex Christensen.
+
+        Test: storage/indexeddb/modern/objectstore-attributes.html
+
+        * Modules/indexeddb/IDBObjectStore.h:
+
+        * Modules/indexeddb/client/IDBAnyImpl.cpp:
+        (WebCore::IDBClient::IDBAny::IDBAny):
+        * Modules/indexeddb/client/IDBAnyImpl.h:
+        (WebCore::IDBClient::IDBAny::create):
+
+        * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+        (WebCore::IDBClient::IDBObjectStore::name):
+        (WebCore::IDBClient::IDBObjectStore::keyPathAny):
+        (WebCore::IDBClient::IDBObjectStore::keyPath):
+        (WebCore::IDBClient::IDBObjectStore::transaction):
+        (WebCore::IDBClient::IDBObjectStore::id): Deleted.
+        * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+
+        * Modules/indexeddb/legacy/LegacyObjectStore.h:
+        (WebCore::LegacyObjectStore::transaction):
+
 2015-10-28  Hunseop Jeong  <hs85.jeong@samsung.com>
 
         Replace 0 and NULL with nullptr in WebCore/editing.
index 379873ebeadb1601512bfb10faed2c3866ac027c..b57f0c60fbb197a7c0777407066d6fcf90d458bd 100644 (file)
@@ -59,12 +59,11 @@ public:
     virtual ~IDBObjectStore() { }
 
     // Implement the IDBObjectStore IDL
-    virtual int64_t id() const = 0;
     virtual const String name() const = 0;
     virtual RefPtr<IDBAny> keyPathAny() const = 0;
     virtual const IDBKeyPath keyPath() const = 0;
     virtual RefPtr<DOMStringList> indexNames() const = 0;
-    virtual RefPtr<IDBTransaction> transaction() const = 0;
+    virtual RefPtr<IDBTransaction> transaction() = 0;
     virtual bool autoIncrement() const = 0;
 
     virtual RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) = 0;
index 7e9a137638bc501b7b85767d11051ecb4c7fcad5..0b54601a8a2ba07aee4b948ae4169e59b696973b 100644 (file)
@@ -48,6 +48,12 @@ IDBAny::IDBAny(Ref<IDBObjectStore>&& objectStore)
 {
 }
 
+IDBAny::IDBAny(const IDBKeyPath& keyPath)
+    : m_type(IDBAny::Type::KeyPath)
+    , m_idbKeyPath(keyPath)
+{
+}
+
 IDBAny::IDBAny(const Deprecated::ScriptValue& value)
     : m_type(IDBAny::Type::ScriptValue)
     , m_scriptValue(value)
index 09c42b1461b81712916c2d9a267894a2f4b4968b..9031d3650c472bfe3a778a845f693b42b0ad145f 100644 (file)
@@ -47,6 +47,11 @@ public:
         return adoptRef(new IDBAny(WTF::move(objectStore)));
     }
 
+    static RefPtr<IDBAny> create(const IDBKeyPath& keyPath)
+    {
+        return adoptRef(new IDBAny(keyPath));
+    }
+
     static RefPtr<IDBAny> create(const Deprecated::ScriptValue& value)
     {
         return adoptRef(new IDBAny(value));
@@ -73,9 +78,9 @@ public:
 private:
     explicit IDBAny(Ref<IDBDatabase>&&);
     explicit IDBAny(Ref<IDBObjectStore>&&);
+    explicit IDBAny(const IDBKeyPath&);
     explicit IDBAny(const Deprecated::ScriptValue&);
 
-
     IDBAny::Type m_type { IDBAny::Type::Undefined };
     RefPtr<IDBDatabase> m_database;
     RefPtr<IDBObjectStore> m_objectStore;
index b02cc15ce072ba8e36a62a3831de44404945c661..89c206bec105d4247a79bd552c02bd747fe91dbc 100644 (file)
@@ -56,24 +56,19 @@ IDBObjectStore::~IDBObjectStore()
 {
 }
 
-int64_t IDBObjectStore::id() const
-{
-    RELEASE_ASSERT_NOT_REACHED();
-}
-
 const String IDBObjectStore::name() const
 {
-    RELEASE_ASSERT_NOT_REACHED();
+    return m_info.name();
 }
 
 RefPtr<WebCore::IDBAny> IDBObjectStore::keyPathAny() const
 {
-    RELEASE_ASSERT_NOT_REACHED();
+    return IDBAny::create(m_info.keyPath());
 }
 
 const IDBKeyPath IDBObjectStore::keyPath() const
 {
-    RELEASE_ASSERT_NOT_REACHED();
+    return m_info.keyPath();
 }
 
 RefPtr<DOMStringList> IDBObjectStore::indexNames() const
@@ -81,9 +76,9 @@ RefPtr<DOMStringList> IDBObjectStore::indexNames() const
     RELEASE_ASSERT_NOT_REACHED();
 }
 
-RefPtr<WebCore::IDBTransaction> IDBObjectStore::transaction() const
+RefPtr<WebCore::IDBTransaction> IDBObjectStore::transaction()
 {
-    RELEASE_ASSERT_NOT_REACHED();
+    return &m_transaction.get();
 }
 
 bool IDBObjectStore::autoIncrement() const
index bf8218368f4a1fe07375a2e26ee07411769a82ee..9839260486697fee59a06fd23e4439ed31e130c9 100644 (file)
@@ -47,12 +47,11 @@ public:
     virtual ~IDBObjectStore() override final;
 
     // Implement the IDBObjectStore IDL
-    virtual int64_t id() const override final;
     virtual const String name() const override final;
     virtual RefPtr<WebCore::IDBAny> keyPathAny() const override final;
     virtual const IDBKeyPath keyPath() const override final;
     virtual RefPtr<DOMStringList> indexNames() const override final;
-    virtual RefPtr<WebCore::IDBTransaction> transaction() const override final;
+    virtual RefPtr<WebCore::IDBTransaction> transaction() override final;
     virtual bool autoIncrement() const override final;
 
     virtual RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
index 1279cfa31823d8246360e5fe5f9a7a5c22f858d7..735379cc610307b77638e8201c85787b1e7502ca 100644 (file)
@@ -64,7 +64,7 @@ public:
     RefPtr<IDBAny> keyPathAny() const { return LegacyAny::create(m_metadata.keyPath); }
     const IDBKeyPath keyPath() const { return m_metadata.keyPath; }
     RefPtr<DOMStringList> indexNames() const;
-    RefPtr<IDBTransaction> transaction() const { return m_transaction; }
+    RefPtr<IDBTransaction> transaction() { return m_transaction; }
     bool autoIncrement() const { return m_metadata.autoIncrement; }
 
     RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&);