Title: [98154] trunk
Revision
98154
Author
commit-qu...@webkit.org
Date
2011-10-21 14:30:11 -0700 (Fri, 21 Oct 2011)

Log Message

IndexedDB: objectStore.transaction property should be readonly
https://bugs.webkit.org/show_bug.cgi?id=62395

Patch by Joshua Bell <jsb...@chromium.org> on 2011-10-21
Reviewed by Tony Chang.

Source/WebCore:

Implement the IDBObjectStore.transaction property defined by the spec.

Test: storage/indexeddb/readonly-properties.html

* storage/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::transaction):
* storage/IDBObjectStore.h:
* storage/IDBObjectStore.idl:

LayoutTests:

* storage/indexeddb/objectstore-basics-expected.txt:
* storage/indexeddb/objectstore-basics.html:
* storage/indexeddb/readonly-properties-expected.txt: Added.
* storage/indexeddb/readonly-properties.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98153 => 98154)


--- trunk/LayoutTests/ChangeLog	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/LayoutTests/ChangeLog	2011-10-21 21:30:11 UTC (rev 98154)
@@ -1,3 +1,15 @@
+2011-10-21  Joshua Bell  <jsb...@chromium.org>
+
+        IndexedDB: objectStore.transaction property should be readonly
+        https://bugs.webkit.org/show_bug.cgi?id=62395
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/objectstore-basics-expected.txt:
+        * storage/indexeddb/objectstore-basics.html:
+        * storage/indexeddb/readonly-properties-expected.txt: Added.
+        * storage/indexeddb/readonly-properties.html: Added.
+
 2011-10-21  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Unreviewed gardening, yet another flaky crashing test.

Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt (98153 => 98154)


--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt	2011-10-21 21:30:11 UTC (rev 98154)
@@ -39,6 +39,7 @@
 store = setVersionTrans.objectStore('storeName')
 index = store.createIndex('indexFail', 'x')
 PASS db.version is "new version"
+PASS store.transaction is setVersionTrans
 PASS store.indexNames is ['indexName']
 PASS store.indexNames.length is 1
 PASS store.indexNames.contains('') is false

Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics.html (98153 => 98154)


--- trunk/LayoutTests/storage/indexeddb/objectstore-basics.html	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics.html	2011-10-21 21:30:11 UTC (rev 98154)
@@ -116,6 +116,7 @@
 function checkMetadata()
 {
     shouldBeEqualToString("db.version", "new version");
+    shouldBe("store.transaction", "setVersionTrans");
     shouldBe("store.indexNames", "['indexName']");
     shouldBe("store.indexNames.length", "1");
     shouldBe("store.indexNames.contains('')", "false");

Added: trunk/LayoutTests/storage/indexeddb/readonly-properties-expected.txt (0 => 98154)


--- trunk/LayoutTests/storage/indexeddb/readonly-properties-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/readonly-properties-expected.txt	2011-10-21 21:30:11 UTC (rev 98154)
@@ -0,0 +1,26 @@
+Test IndexedDB readonly properties
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
+PASS indexedDB == null is false
+IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;
+PASS IDBDatabaseException == null is false
+IDBCursor = window.IDBCursor || window.webkitIDBCursor;
+PASS IDBCursor == null is false
+IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
+PASS IDBKeyRange == null is false
+indexedDB.open(name, description)
+db = event.target.result
+request = db.setVersion('1')
+transaction = event.target.result;
+Deleted all object stores.
+objectStore = db.createObjectStore('foo');
+trying to set readonly property objectStore.transaction
+objectStore.transaction = this
+PASS objectStore.transaction is still [object IDBTransaction]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/readonly-properties.html (0 => 98154)


--- trunk/LayoutTests/storage/indexeddb/readonly-properties.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/readonly-properties.html	2011-10-21 21:30:11 UTC (rev 98154)
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("Test IndexedDB readonly properties");
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+function setReadonlyProperty(property, value)
+{
+    oldValue = eval(property);
+    debug("trying to set readonly property " + property);
+    evalAndLog(property + " = " + value);
+    newValue = eval(property);
+    if (oldValue == newValue) {
+        testPassed(property + " is still " + oldValue);
+    } else {
+        testFailed(property + " value was changed to " + newValue);
+    }
+}
+
+function test()
+{
+    indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
+    shouldBeFalse("indexedDB == null");
+    IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
+    shouldBeFalse("IDBDatabaseException == null");
+    IDBCursor = evalAndLog("IDBCursor = window.IDBCursor || window.webkitIDBCursor;");
+    shouldBeFalse("IDBCursor == null");
+    IDBKeyRange = evalAndLog("IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;");
+    shouldBeFalse("IDBKeyRange == null");
+
+    name = "foo";
+    description = "My Test Database";
+    request = evalAndLog("indexedDB.open(name, description)");
+    request._onsuccess_ = openSuccess;
+    request._onerror_ = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+    db = evalAndLog("db = event.target.result");
+    request = evalAndLog("request = db.setVersion('1')");
+    request._onsuccess_ = createAndPopulateObjectStore;
+    request._onerror_ = unexpectedErrorCallback;
+}
+
+function createAndPopulateObjectStore()
+{
+    transaction = evalAndLog("transaction = event.target.result;");
+    deleteAllObjectStores(db);
+    objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
+    setReadonlyProperty("objectStore.transaction", "this");
+    done();
+}
+
+var successfullyParsed = true;
+
+test();
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (98153 => 98154)


--- trunk/Source/WebCore/ChangeLog	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/Source/WebCore/ChangeLog	2011-10-21 21:30:11 UTC (rev 98154)
@@ -1,3 +1,19 @@
+2011-10-21  Joshua Bell  <jsb...@chromium.org>
+
+        IndexedDB: objectStore.transaction property should be readonly
+        https://bugs.webkit.org/show_bug.cgi?id=62395
+
+        Reviewed by Tony Chang.
+
+        Implement the IDBObjectStore.transaction property defined by the spec.
+
+        Test: storage/indexeddb/readonly-properties.html
+
+        * storage/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::transaction):
+        * storage/IDBObjectStore.h:
+        * storage/IDBObjectStore.idl:
+
 2011-10-21  Adam Barth  <aba...@webkit.org>
 
         Event.h has too many virtual isMumbleEvent() functions

Modified: trunk/Source/WebCore/storage/IDBObjectStore.cpp (98153 => 98154)


--- trunk/Source/WebCore/storage/IDBObjectStore.cpp	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/Source/WebCore/storage/IDBObjectStore.cpp	2011-10-21 21:30:11 UTC (rev 98154)
@@ -68,6 +68,11 @@
     return m_objectStore->indexNames();
 }
 
+IDBTransaction* IDBObjectStore::transaction() const
+{
+    return m_transaction.get();
+}
+
 PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec)
 {
     RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());

Modified: trunk/Source/WebCore/storage/IDBObjectStore.h (98153 => 98154)


--- trunk/Source/WebCore/storage/IDBObjectStore.h	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/Source/WebCore/storage/IDBObjectStore.h	2011-10-21 21:30:11 UTC (rev 98154)
@@ -58,6 +58,7 @@
     String name() const;
     String keyPath() const;
     PassRefPtr<DOMStringList> indexNames() const;
+    IDBTransaction* transaction() const;
 
     // FIXME: Try to modify the code generator so this is unneeded.
     PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return add(context, value, 0, ec);  }

Modified: trunk/Source/WebCore/storage/IDBObjectStore.idl (98153 => 98154)


--- trunk/Source/WebCore/storage/IDBObjectStore.idl	2011-10-21 21:26:15 UTC (rev 98153)
+++ trunk/Source/WebCore/storage/IDBObjectStore.idl	2011-10-21 21:30:11 UTC (rev 98154)
@@ -31,6 +31,7 @@
         readonly attribute [ConvertNullStringTo=Null] DOMString name;
         readonly attribute [ConvertNullStringTo=Null] DOMString keyPath;
         readonly attribute DOMStringList indexNames;
+        readonly attribute IDBTransaction transaction;
 
         [CallWith=ScriptExecutionContext] IDBRequest put(in SerializedScriptValue value, in [Optional] IDBKey key)
             raises (IDBDatabaseException);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to