Title: [104481] trunk
Revision
104481
Author
[email protected]
Date
2012-01-09 13:08:32 -0800 (Mon, 09 Jan 2012)

Log Message

IndexedDB: Make WebIDBDatabase::close() idempotent
https://bugs.webkit.org/show_bug.cgi?id=75751

Source/WebKit/chromium:

Allow Chromium's back-end to safely trigger the cleanup that occurs
when a database connection is closed, without tracking whether or not
the connection was previous closed by script.

Patch by Joshua Bell <[email protected]> on 2012-01-09
Reviewed by Tony Chang.

* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::close):

LayoutTests:

Verify that calling IDBDatabase.close() twice from script is harmless.
Note that the tests pass without the related code change in the bug,
which is just for non-script use by the chromium port.

Patch by Joshua Bell <[email protected]> on 2012-01-09
Reviewed by Tony Chang.

* storage/indexeddb/database-basics-expected.txt:
* storage/indexeddb/database-basics.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104480 => 104481)


--- trunk/LayoutTests/ChangeLog	2012-01-09 20:58:20 UTC (rev 104480)
+++ trunk/LayoutTests/ChangeLog	2012-01-09 21:08:32 UTC (rev 104481)
@@ -1,3 +1,17 @@
+2012-01-09  Joshua Bell  <[email protected]>
+
+        IndexedDB: Make WebIDBDatabase::close() idempotent
+        https://bugs.webkit.org/show_bug.cgi?id=75751
+
+        Verify that calling IDBDatabase.close() twice from script is harmless.
+        Note that the tests pass without the related code change in the bug,
+        which is just for non-script use by the chromium port.
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/database-basics-expected.txt:
+        * storage/indexeddb/database-basics.html:
+
 2012-01-09  Elliot Poger  <[email protected]>
 
         remove reference to cg-specific test

Modified: trunk/LayoutTests/storage/indexeddb/database-basics-expected.txt (104480 => 104481)


--- trunk/LayoutTests/storage/indexeddb/database-basics-expected.txt	2012-01-09 20:58:20 UTC (rev 104480)
+++ trunk/LayoutTests/storage/indexeddb/database-basics-expected.txt	2012-01-09 21:08:32 UTC (rev 104481)
@@ -3,7 +3,11 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-webkitIndexedDB.open('database-basics')
+indexedDB = window.indexedDB || window.webkitIndexedDB
+PASS indexedDB != null is true
+IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException
+PASS IDBDatabaseException != null is true
+indexedDB.open('database-basics')
 db = event.target.result
 db.setVersion('new version')
 setVersionSuccess():
@@ -43,6 +47,13 @@
 PASS db.objectStoreNames.contains('') is false
 PASS db.objectStoreNames.contains('test456') is false
 PASS db.objectStoreNames.contains('test123') is true
+db.close()
+Now that the connection is closed, transaction creation should fail
+Expecting exception from db.transaction('test123')
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.NOT_ALLOWED_ERR
+Call twice, make sure it's harmless
+db.close()
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/database-basics.html (104480 => 104481)


--- trunk/LayoutTests/storage/indexeddb/database-basics.html	2012-01-09 20:58:20 UTC (rev 104480)
+++ trunk/LayoutTests/storage/indexeddb/database-basics.html	2012-01-09 21:08:32 UTC (rev 104481)
@@ -14,7 +14,12 @@
 
 function test()
 {
-    request = evalAndLog("webkitIndexedDB.open('database-basics')");
+    evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB");
+    shouldBeTrue("indexedDB != null");
+    evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException");
+    shouldBeTrue("IDBDatabaseException != null");
+
+    request = evalAndLog("indexedDB.open('database-basics')");
     request._onsuccess_ = openSuccess;
     request._onerror_ = unexpectedErrorCallback;
 }
@@ -104,6 +109,16 @@
 {
     shouldBeEqualToString("db.version", "version b");
     checkObjectStore();
+    testClose();
+}
+
+function testClose()
+{
+    evalAndLog("db.close()");
+    debug("Now that the connection is closed, transaction creation should fail");
+    evalAndExpectException("db.transaction('test123')", "IDBDatabaseException.NOT_ALLOWED_ERR");
+    debug("Call twice, make sure it's harmless");
+    evalAndLog("db.close()");
     done();
 }
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (104480 => 104481)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-01-09 20:58:20 UTC (rev 104480)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-01-09 21:08:32 UTC (rev 104481)
@@ -1,3 +1,17 @@
+2012-01-09  Joshua Bell  <[email protected]>
+
+        IndexedDB: Make WebIDBDatabase::close() idempotent
+        https://bugs.webkit.org/show_bug.cgi?id=75751
+
+        Allow Chromium's back-end to safely trigger the cleanup that occurs
+        when a database connection is closed, without tracking whether or not
+        the connection was previous closed by script.
+
+        Reviewed by Tony Chang.
+
+        * src/WebIDBDatabaseImpl.cpp:
+        (WebKit::WebIDBDatabaseImpl::close):
+
 2012-01-09  Xianzhu Wang  <[email protected]>
 
         Avoid unnecessary TextureManager::reduceMemoryToLimit().

Modified: trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp (104480 => 104481)


--- trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp	2012-01-09 20:58:20 UTC (rev 104480)
+++ trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp	2012-01-09 21:08:32 UTC (rev 104481)
@@ -101,8 +101,10 @@
 {
     // Use the callbacks that ::open gave us so that the backend in
     // multi-process chromium knows which database connection is closing.
-    ASSERT(m_databaseCallbacks);
+    if (!m_databaseCallbacks)
+        return;
     m_databaseBackend->close(m_databaseCallbacks);
+    m_databaseCallbacks = 0;
 }
 
 void WebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to