| Test IndexedDB's transaction and objectStore calls |
| |
| On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| |
| |
| indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB; |
| |
| indexedDB.deleteDatabase(dbname) |
| indexedDB.open(dbname) |
| db.createObjectStore('a') |
| db.createObjectStore('b') |
| db.createObjectStore('store').createIndex('index', 'some_path') |
| |
| trans = db.transaction(['a']) |
| trans.objectStore('a') |
| Expecting exception from trans.objectStore('b') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| trans = db.transaction(['a']) |
| trans.objectStore('a') |
| Expecting exception from trans.objectStore('b') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| trans = db.transaction(['b']) |
| trans.objectStore('b') |
| Expecting exception from trans.objectStore('a') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| trans = db.transaction(['a', 'b']) |
| trans.objectStore('a') |
| trans.objectStore('b') |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| trans = db.transaction(['b', 'a']) |
| trans.objectStore('a') |
| trans.objectStore('b') |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| Passing a string as the first argument is a shortcut for just one object store: |
| trans = db.transaction('a') |
| trans.objectStore('a') |
| Expecting exception from trans.objectStore('b') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| Expecting exception from trans.objectStore('x') |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found. |
| |
| PASS trans = db.transaction() threw exception TypeError: Not enough arguments. |
| |
| Expecting exception from db.transaction(['x']) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction(['x']) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction(['a', 'x']) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction(['x', 'x']) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction(['a', 'x', 'b']) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| |
| Exception thrown when no stores specified: |
| Expecting exception from db.transaction([]) |
| PASS Exception was thrown. |
| PASS code is DOMException.INVALID_ACCESS_ERR |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty. |
| |
| {} coerces to a string - so no match, but not a type error: |
| Expecting exception from db.transaction({}) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction({mode:0}) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| |
| Overriding the default string coercion makes these work: |
| db.transaction({toString:function(){return 'a';}}) |
| db.transaction([{toString:function(){return 'a';}}]) |
| ... but you still need to specify a real store: |
| Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
| PASS Exception was thrown. |
| PASS code is DOMException.NOT_FOUND_ERR |
| PASS ename is 'NotFoundError' |
| Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. |
| |
| trans = db.transaction(['store']) |
| PASS trans is non-null. |
| store = trans.objectStore('store') |
| PASS store is non-null. |
| store.get('some_key') |
| transaction complete, ensuring methods fail |
| PASS trans is non-null. |
| PASS store is non-null. |
| Expecting exception from trans.objectStore('store') |
| PASS Exception was thrown. |
| PASS code is 11 |
| PASS ename is 'InvalidStateError' |
| Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The transaction finished. |
| Expecting exception from store.index('index') |
| PASS Exception was thrown. |
| PASS code is 11 |
| PASS ename is 'InvalidStateError' |
| Exception message: Failed to execute 'index' on 'IDBObjectStore': The transaction is finished. |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |