jorlow@chromium.org | be25181 | 2010-07-26 17:37:50 +0000 | [diff] [blame] | 1 | Test the basics of IndexedDB's IDBDatabase. |
jorlow@chromium.org | 6ef2aff | 2010-05-17 11:20:45 +0000 | [diff] [blame] | 2 | |
| 3 | On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| 4 | |
| 5 | |
dgrogan@chromium.org | 8750ff6 | 2012-03-14 21:20:56 +0000 | [diff] [blame] | 6 | indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB; |
dgrogan@chromium.org | 8750ff6 | 2012-03-14 21:20:56 +0000 | [diff] [blame] | 7 | |
dgrogan@chromium.org | 294daf0 | 2012-11-14 05:03:50 +0000 | [diff] [blame] | 8 | indexedDB.deleteDatabase(dbname) |
| 9 | indexedDB.open(dbname) |
| 10 | Test that you can't open a transaction while in a versionchange transaction |
| 11 | Expecting exception from db.transaction("doesntExist") |
commit-queue@webkit.org | cfbe763 | 2012-06-14 08:06:07 +0000 | [diff] [blame] | 12 | PASS Exception was thrown. |
| 13 | PASS code is DOMException.INVALID_STATE_ERR |
| 14 | PASS ename is 'InvalidStateError' |
beidson@apple.com | 5529122 | 2015-12-07 20:27:37 +0000 | [diff] [blame] | 15 | Exception message: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running. |
dgrogan@chromium.org | 294daf0 | 2012-11-14 05:03:50 +0000 | [diff] [blame] | 16 | PASS db.version is 1 |
| 17 | PASS db.name is "database-basics.html" |
hans@chromium.org | dccbdc6 | 2010-11-26 11:03:59 +0000 | [diff] [blame] | 18 | PASS db.objectStoreNames is [] |
| 19 | PASS db.objectStoreNames.length is 0 |
| 20 | PASS db.objectStoreNames.contains('') is false |
arko@motorola.com | f07a31e | 2012-08-07 07:00:09 +0000 | [diff] [blame] | 21 | PASS db.objectStoreNames[0] is undefined. |
hans@chromium.org | dccbdc6 | 2010-11-26 11:03:59 +0000 | [diff] [blame] | 22 | PASS db.objectStoreNames.item(0) is null |
jorlow@chromium.org | fb3c157 | 2010-09-03 13:15:28 +0000 | [diff] [blame] | 23 | db.createObjectStore("test123") |
hans@chromium.org | dccbdc6 | 2010-11-26 11:03:59 +0000 | [diff] [blame] | 24 | PASS db.objectStoreNames is ['test123'] |
| 25 | PASS db.objectStoreNames.length is 1 |
| 26 | PASS db.objectStoreNames.contains('') is false |
| 27 | PASS db.objectStoreNames.contains('test456') is false |
| 28 | PASS db.objectStoreNames.contains('test123') is true |
cdumez@apple.com | a1fa631 | 2016-12-01 20:33:05 +0000 | [diff] [blame] | 29 | PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments. |
dgrogan@chromium.org | 294daf0 | 2012-11-14 05:03:50 +0000 | [diff] [blame] | 30 | db.close() |
| 31 | request = indexedDB.open(dbname, 2) |
| 32 | db = event.target.result |
| 33 | PASS db.version is 2 |
| 34 | PASS db.name is "database-basics.html" |
hans@chromium.org | dccbdc6 | 2010-11-26 11:03:59 +0000 | [diff] [blame] | 35 | PASS db.objectStoreNames is ['test123'] |
| 36 | PASS db.objectStoreNames.length is 1 |
| 37 | PASS db.objectStoreNames.contains('') is false |
| 38 | PASS db.objectStoreNames.contains('test456') is false |
| 39 | PASS db.objectStoreNames.contains('test123') is true |
cdumez@apple.com | a1fa631 | 2016-12-01 20:33:05 +0000 | [diff] [blame] | 40 | PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments. |
andreip@google.com | 1b2e471 | 2010-10-06 22:52:22 +0000 | [diff] [blame] | 41 | db.createObjectStore("test456") |
dgrogan@chromium.org | 294daf0 | 2012-11-14 05:03:50 +0000 | [diff] [blame] | 42 | setVersionTrans = event.target.transaction |
jsbell@chromium.org | 6b1c22e | 2012-05-19 23:36:46 +0000 | [diff] [blame] | 43 | PASS setVersionTrans is non-null. |
dgrogan@chromium.org | 294daf0 | 2012-11-14 05:03:50 +0000 | [diff] [blame] | 44 | setVersionTrans.abort() |
| 45 | PASS db.version is 1 |
hans@chromium.org | dccbdc6 | 2010-11-26 11:03:59 +0000 | [diff] [blame] | 46 | PASS db.objectStoreNames is ['test123'] |
| 47 | PASS db.objectStoreNames.length is 1 |
| 48 | PASS db.objectStoreNames.contains('') is false |
| 49 | PASS db.objectStoreNames.contains('test456') is false |
| 50 | PASS db.objectStoreNames.contains('test123') is true |
cdumez@apple.com | a1fa631 | 2016-12-01 20:33:05 +0000 | [diff] [blame] | 51 | PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments. |
commit-queue@webkit.org | 797a6c2 | 2012-01-09 21:08:32 +0000 | [diff] [blame] | 52 | db.close() |
| 53 | Now that the connection is closed, transaction creation should fail |
| 54 | Expecting exception from db.transaction('test123') |
| 55 | PASS Exception was thrown. |
commit-queue@webkit.org | f38860d | 2012-06-07 21:11:36 +0000 | [diff] [blame] | 56 | PASS code is DOMException.INVALID_STATE_ERR |
| 57 | PASS ename is 'InvalidStateError' |
beidson@apple.com | 5529122 | 2015-12-07 20:27:37 +0000 | [diff] [blame] | 58 | Exception message: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. |
commit-queue@webkit.org | 797a6c2 | 2012-01-09 21:08:32 +0000 | [diff] [blame] | 59 | Call twice, make sure it's harmless |
| 60 | db.close() |
jorlow@chromium.org | 6ef2aff | 2010-05-17 11:20:45 +0000 | [diff] [blame] | 61 | PASS successfullyParsed is true |
| 62 | |
| 63 | TEST COMPLETE |
andreip@google.com | 6d3c4e6 | 2010-09-28 18:28:21 +0000 | [diff] [blame] | 64 | |