IndexedDB: Throw native TypeErrors per spec
https://bugs.webkit.org/show_bug.cgi?id=91679

Reviewed by Kentaro Hara.

Source/WebCore:

Per the IDB spec, the advance(), openCursor(), openKeyCursor() and transaction()
methods supposed to throw true native JavaScript TypeError objects as exceptions
rather than DOMException objects. Implement this by adding a special DOMException
code that is tested for in the binding layer.

Tests: storage/indexeddb/cursor-advance.html
       storage/indexeddb/index-basics.html
       storage/indexeddb/index-basics-workers.html
       storage/indexeddb/objectstore-cursor.html
       storage/indexeddb/transaction-basics.html

* Modules/indexeddb/IDBCursor.cpp: Use the new DOMException code.
(WebCore::IDBCursor::advance):
(WebCore::IDBCursor::stringToDirection):
(WebCore::IDBCursor::directionToString):
* Modules/indexeddb/IDBDatabase.cpp: Ditto.
(WebCore::IDBDatabase::setVersion):
* Modules/indexeddb/IDBDatabaseException.cpp: Remove temporary cruft/mark as legacy.
(WebCore):
* Modules/indexeddb/IDBDatabaseException.h: Ditto.
* Modules/indexeddb/IDBDatabaseException.idl: Ditto.
* Modules/indexeddb/IDBFactory.cpp: Use the new DOMException code.
(WebCore::IDBFactory::open):
(WebCore::IDBFactory::deleteDatabase):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::createIndex): Use the new DOMException code.
* Modules/indexeddb/IDBTransaction.cpp: Use the new DOMException code.
(WebCore::IDBTransaction::stringToMode):
(WebCore::IDBTransaction::modeToString):
* bindings/js/JSDOMBinding.cpp:
(WebCore::setDOMException): Intercept new DOMException code, throw native TypeError.
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::setDOMException): Ditto.
* dom/ExceptionCode.h: Add new DOMException code.

LayoutTests:

* storage/indexeddb/cursor-advance-expected.txt:
* storage/indexeddb/index-basics-expected.txt:
* storage/indexeddb/index-basics-workers-expected.txt:
* storage/indexeddb/objectstore-cursor-expected.txt:
* storage/indexeddb/resources/cursor-advance.js:
(testBadAdvance.advanceBadly):
(testBadAdvance):
* storage/indexeddb/resources/index-basics.js:
(openKeyCursor):
(openObjectCursor):
* storage/indexeddb/resources/objectstore-cursor.js:
(deleteExisting):
* storage/indexeddb/resources/transaction-basics.js:
(testInvalidMode):
* storage/indexeddb/transaction-basics-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123112 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt b/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt
index 8b3ea10..2015c05 100644
--- a/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt
+++ b/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt
@@ -11,7 +11,13 @@
 trans = event.target.result
 PASS trans is non-null.
 Deleted all object stores.
-db.createObjectStore('someObjectStore')
+objectStore = db.createObjectStore('someObjectStore')
+
+Verify that specifying an invalid direction raises an exception:
+Expecting TypeError exception from objectStore.openCursor(0, 'invalid-direction')
+PASS Exception was thrown.
+PASS objectStore.openCursor(0, 'invalid-direction') threw TypeError: Type error
+
 objectStore.add('', testData[nextToAdd])
 objectStore.add('', testData[nextToAdd])
 objectStore.add('', testData[nextToAdd])