Title: [131668] trunk
Revision
131668
Author
[email protected]
Date
2012-10-17 16:51:03 -0700 (Wed, 17 Oct 2012)

Log Message

IndexedDB: Closing connection in upgradeneeded should result in error event
https://bugs.webkit.org/show_bug.cgi?id=99486

Reviewed by Tony Chang.

Source/WebCore:

The IDB spec requires that "...if connection is closed, return a DOMError of type AbortError".
This was being handled during the "enqueue" phase, which was too early either for synchronously
executing scripts or asynchronous messaging in multiprocess ports (crbug.com/150691). Move the
logic to the "dispatch" phase.

Test: storage/indexeddb/intversion-close-in-oncomplete.html

* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onSuccess): Move success to error morphing from here...
(WebCore::IDBOpenDBRequest::dispatchEvent): To here.
* Modules/indexeddb/IDBOpenDBRequest.h:
(IDBOpenDBRequest):

LayoutTests:

Updated test expectation - error, not success.

* storage/indexeddb/intversion-close-in-oncomplete-expected.txt:
* storage/indexeddb/resources/intversion-close-in-oncomplete.js:
(deleteSuccess):
(upgradeNeeded.transaction.oncomplete):
(upgradeNeeded):
(openError):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (131667 => 131668)


--- trunk/LayoutTests/ChangeLog	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/LayoutTests/ChangeLog	2012-10-17 23:51:03 UTC (rev 131668)
@@ -1,3 +1,19 @@
+2012-10-17  Joshua Bell  <[email protected]>
+
+        IndexedDB: Closing connection in upgradeneeded should result in error event
+        https://bugs.webkit.org/show_bug.cgi?id=99486
+
+        Reviewed by Tony Chang.
+
+        Updated test expectation - error, not success.
+
+        * storage/indexeddb/intversion-close-in-oncomplete-expected.txt:
+        * storage/indexeddb/resources/intversion-close-in-oncomplete.js:
+        (deleteSuccess):
+        (upgradeNeeded.transaction.oncomplete):
+        (upgradeNeeded):
+        (openError):
+
 2012-10-17  Ryosuke Niwa  <[email protected]>
 
         Build fix after r131651.

Modified: trunk/LayoutTests/storage/indexeddb/intversion-close-in-oncomplete-expected.txt (131667 => 131668)


--- trunk/LayoutTests/storage/indexeddb/intversion-close-in-oncomplete-expected.txt	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/LayoutTests/storage/indexeddb/intversion-close-in-oncomplete-expected.txt	2012-10-17 23:51:03 UTC (rev 131668)
@@ -19,10 +19,10 @@
 sawTransactionComplete = true
 db.close()
 
-openSuccess():
+openError():
 PASS sawTransactionComplete is true
-db = event.target.result
-PASS db.version is 7
+PASS event.target.result is null
+PASS event.target.error.name is "AbortError"
 Expecting exception from transaction = db.transaction('os', 'readwrite')
 PASS Exception was thrown.
 PASS code is DOMException.INVALID_STATE_ERR

Modified: trunk/LayoutTests/storage/indexeddb/resources/intversion-close-in-oncomplete.js (131667 => 131668)


--- trunk/LayoutTests/storage/indexeddb/resources/intversion-close-in-oncomplete.js	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/LayoutTests/storage/indexeddb/resources/intversion-close-in-oncomplete.js	2012-10-17 23:51:03 UTC (rev 131668)
@@ -17,18 +17,16 @@
 
 function deleteSuccess(evt) {
     evalAndLog("request = indexedDB.open(dbname, 7)");
-    request._onsuccess_ = openSuccess;
     request._onupgradeneeded_ = upgradeNeeded;
+    request._onerror_ = openError;
     request._onblocked_ = unexpectedBlockedCallback;
-    request._onerror_ = unexpectedErrorCallback;
+    request._onsuccess_ = unexpectedSuccessCallback;
 }
 
 var sawTransactionComplete = false;
 function upgradeNeeded(evt)
 {
-    event = evt;
-    debug("");
-    debug("upgradeNeeded():");
+    preamble(evt);
     evalAndLog("db = event.target.result");
     shouldBe("event.newVersion", "7");
     evalAndLog("db.createObjectStore('os')");
@@ -41,17 +39,15 @@
         debug("transaction.oncomplete:");
         evalAndLog("sawTransactionComplete = true");
         evalAndLog("db.close()");
-    }
+    };
 }
 
-function openSuccess(evt)
+function openError(evt)
 {
-    event = evt;
-    debug("");
-    debug("openSuccess():");
+    preamble(evt);
     shouldBeTrue("sawTransactionComplete");
-    evalAndLog("db = event.target.result");
-    shouldBe('db.version', "7");
+    shouldBeNull("event.target.result");
+    shouldBeEqualToString("event.target.error.name", "AbortError");
     evalAndExpectException("transaction = db.transaction('os', 'readwrite')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
     finishJSTest();
 }

Modified: trunk/Source/WebCore/ChangeLog (131667 => 131668)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/Source/WebCore/ChangeLog	2012-10-17 23:51:03 UTC (rev 131668)
@@ -1,3 +1,23 @@
+2012-10-17  Joshua Bell  <[email protected]>
+
+        IndexedDB: Closing connection in upgradeneeded should result in error event
+        https://bugs.webkit.org/show_bug.cgi?id=99486
+
+        Reviewed by Tony Chang.
+
+        The IDB spec requires that "...if connection is closed, return a DOMError of type AbortError".
+        This was being handled during the "enqueue" phase, which was too early either for synchronously
+        executing scripts or asynchronous messaging in multiprocess ports (crbug.com/150691). Move the
+        logic to the "dispatch" phase.
+
+        Test: storage/indexeddb/intversion-close-in-oncomplete.html
+
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::onSuccess): Move success to error morphing from here...
+        (WebCore::IDBOpenDBRequest::dispatchEvent): To here.
+        * Modules/indexeddb/IDBOpenDBRequest.h:
+        (IDBOpenDBRequest):
+
 2012-10-17  Elliott Sprehn  <[email protected]>
 
         Use virtual dispatch to create ContentData renderers

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp (131667 => 131668)


--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp	2012-10-17 23:51:03 UTC (rev 131668)
@@ -114,15 +114,6 @@
         idbDatabase = m_result->idbDatabase();
         ASSERT(idbDatabase);
         ASSERT(!m_databaseCallbacks);
-
-        // If the connection closed between onUpgradeNeeded and onSuccess, an error
-        // should be fired instead of success. The back-end may not be aware of
-        // the closing state if the events are asynchronously delivered.
-        if (idbDatabase->isClosePending()) {
-            m_result.clear();
-            onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "The connection was closed."));
-            return;
-        }
     } else {
         ASSERT(m_databaseCallbacks);
         idbDatabase = IDBDatabase::create(scriptExecutionContext(), backend, m_databaseCallbacks);
@@ -143,7 +134,19 @@
     return true;
 }
 
+bool IDBOpenDBRequest::dispatchEvent(PassRefPtr<Event> event)
+{
+    // If the connection closed between onUpgradeNeeded and the delivery of the "success" event,
+    // an "error" event should be fired instead.
+    if (event->type() == eventNames().successEvent && m_result->idbDatabase()->isClosePending()) {
+        m_result.clear();
+        onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "The connection was closed."));
+        return false;
+    }
 
+    return IDBRequest::dispatchEvent(event);
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h (131667 => 131668)


--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h	2012-10-17 23:35:30 UTC (rev 131667)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h	2012-10-17 23:51:03 UTC (rev 131668)
@@ -47,6 +47,7 @@
 
     // EventTarget
     virtual const AtomicString& interfaceName() const;
+    virtual bool dispatchEvent(PassRefPtr<Event>);
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(blocked);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(upgradeneeded);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to