IndexedDB: IDBTransaction::abort() should throw DOMException
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2012 02:30:34 +0000 (02:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2012 02:30:34 +0000 (02:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92069

Patch by Xingnan Wang <xingnan.wang@intel.com> on 2012-07-25
Reviewed by Kentaro Hara.

Source/WebCore:

Keep aligned with the W3C spec.
http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBTransaction-abort-void

Test: storage/indexeddb/transaction-abort.html.

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::abort):
(WebCore):
* Modules/indexeddb/IDBTransaction.h:
(IDBTransaction):
* Modules/indexeddb/IDBTransaction.idl:

LayoutTests:

Add the exception test for IDBTransaction::abort().

* storage/indexeddb/resources/transaction-abort.js:
(transactionAborted):
* storage/indexeddb/transaction-abort-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/resources/transaction-abort.js
LayoutTests/storage/indexeddb/transaction-abort-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBTransaction.idl

index 61e408e..fab92fb 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-25  Xingnan Wang  <xingnan.wang@intel.com>
+
+        IndexedDB: IDBTransaction::abort() should throw DOMException
+        https://bugs.webkit.org/show_bug.cgi?id=92069
+
+        Reviewed by Kentaro Hara.
+
+        Add the exception test for IDBTransaction::abort().
+
+        * storage/indexeddb/resources/transaction-abort.js:
+        (transactionAborted):
+        * storage/indexeddb/transaction-abort-expected.txt:
+
 2012-07-25  Joshua Netterfield  <jnetterfield@rim.com>
 
         [BlackBerry] Update fast/canvas/webgl expectations
index 6ade025..c688b63 100644 (file)
@@ -90,6 +90,9 @@ function transactionAborted()
     abortFired = true;
 
     evalAndExpectException("store.add({x: 'value5', y: 'zzz5'}, 'key5')", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
+
+    evalAndExpectException("trans.abort()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
     finishJSTest();
 }
 
index e929cd7..62360d9 100644 (file)
@@ -45,6 +45,10 @@ Expecting exception from store.add({x: 'value5', y: 'zzz5'}, 'key5')
 PASS Exception was thrown.
 PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
 PASS ename is 'TransactionInactiveError'
+Expecting exception from trans.abort()
+PASS Exception was thrown.
+PASS code is DOMException.INVALID_STATE_ERR
+PASS ename is 'InvalidStateError'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 2ec127a..6f39794 100644 (file)
@@ -1,3 +1,22 @@
+2012-07-25  Xingnan Wang  <xingnan.wang@intel.com>
+
+        IndexedDB: IDBTransaction::abort() should throw DOMException
+        https://bugs.webkit.org/show_bug.cgi?id=92069
+
+        Reviewed by Kentaro Hara.
+
+        Keep aligned with the W3C spec.
+        http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBTransaction-abort-void
+
+        Test: storage/indexeddb/transaction-abort.html.
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::abort):
+        (WebCore):
+        * Modules/indexeddb/IDBTransaction.h:
+        (IDBTransaction):
+        * Modules/indexeddb/IDBTransaction.idl:
+
 2012-07-25  Tony Chang  <tony@chromium.org>
 
         flexitems can overflow the flexbox due to rounding
index a1eaf29..7dd30e9 100644 (file)
@@ -458,7 +458,8 @@ bool IDBRequest::dispatchEvent(PassRefPtr<Event> event)
     if (m_transaction) {
         if (event->type() == eventNames().errorEvent && dontPreventDefault && !m_requestAborted) {
             m_transaction->setError(m_error);
-            m_transaction->abort();
+            ExceptionCode unused;
+            m_transaction->abort(unused);
         }
 
         if (event->type() != eventNames().blockedEvent)
@@ -475,7 +476,8 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 {
     if (m_transaction && !m_requestAborted) {
         m_transaction->setError(DOMError::create(IDBDatabaseException::getErrorName(IDBDatabaseException::IDB_ABORT_ERR)));
-        m_transaction->abort();
+        ExceptionCode unused; 
+        m_transaction->abort(unused);
     }
 }
 
index f5e761e..7612347 100644 (file)
@@ -193,10 +193,13 @@ void IDBTransaction::setActive(bool active)
         m_backend->commit();
 }
 
-void IDBTransaction::abort()
+void IDBTransaction::abort(ExceptionCode& ec)
 {
-    if (m_state == Finishing || m_state == Finished)
+    if (m_state == Finishing || m_state == Finished) {
+        ec = IDBDatabaseException::IDB_INVALID_STATE_ERR;
         return;
+    }
+
     m_state = Finishing;
     m_active = false;
 
@@ -387,7 +390,8 @@ void IDBTransaction::stop()
     ActiveDOMObject::stop();
     m_contextStopped = true;
 
-    abort();
+    ExceptionCode unused;
+    abort(unused);
 }
 
 void IDBTransaction::enqueueEvent(PassRefPtr<Event> event)
index 3037862..1f7af7d 100644 (file)
@@ -78,7 +78,7 @@ public:
     IDBDatabase* db() const { return m_database.get(); }
     PassRefPtr<DOMError> error() const { return m_error; }
     PassRefPtr<IDBObjectStore> objectStore(const String& name, ExceptionCode&);
-    void abort();
+    void abort(ExceptionCode&);
 
     class OpenCursorNotifier {
     public:
index dfa9ed9..b5c207d 100644 (file)
@@ -44,7 +44,8 @@ module storage {
         // Methods
         IDBObjectStore objectStore (in DOMString name)
             raises (IDBDatabaseException);
-        void abort ();
+        void abort ()
+            raises (IDBDatabaseException);
 
         // Events
         attribute EventListener onabort;