blob: 45c5c27dc174d406fbdd9ef5bf2f5b38620cf3a2 [file] [log] [blame]
jorlow@chromium.orgbe251812010-07-26 17:37:50 +00001Test the basics of IndexedDB's IDBDatabase.
jorlow@chromium.org6ef2aff2010-05-17 11:20:45 +00002
3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
dgrogan@chromium.org8750ff62012-03-14 21:20:56 +00006indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
dgrogan@chromium.org8750ff62012-03-14 21:20:56 +00007
dgrogan@chromium.org294daf02012-11-14 05:03:50 +00008indexedDB.deleteDatabase(dbname)
9indexedDB.open(dbname)
10Test that you can't open a transaction while in a versionchange transaction
11Expecting exception from db.transaction("doesntExist")
commit-queue@webkit.orgcfbe7632012-06-14 08:06:07 +000012PASS Exception was thrown.
13PASS code is DOMException.INVALID_STATE_ERR
14PASS ename is 'InvalidStateError'
beidson@apple.com55291222015-12-07 20:27:37 +000015Exception message: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.
dgrogan@chromium.org294daf02012-11-14 05:03:50 +000016PASS db.version is 1
17PASS db.name is "database-basics.html"
hans@chromium.orgdccbdc62010-11-26 11:03:59 +000018PASS db.objectStoreNames is []
19PASS db.objectStoreNames.length is 0
20PASS db.objectStoreNames.contains('') is false
arko@motorola.comf07a31e2012-08-07 07:00:09 +000021PASS db.objectStoreNames[0] is undefined.
hans@chromium.orgdccbdc62010-11-26 11:03:59 +000022PASS db.objectStoreNames.item(0) is null
jorlow@chromium.orgfb3c1572010-09-03 13:15:28 +000023db.createObjectStore("test123")
hans@chromium.orgdccbdc62010-11-26 11:03:59 +000024PASS db.objectStoreNames is ['test123']
25PASS db.objectStoreNames.length is 1
26PASS db.objectStoreNames.contains('') is false
27PASS db.objectStoreNames.contains('test456') is false
28PASS db.objectStoreNames.contains('test123') is true
cdumez@apple.coma1fa6312016-12-01 20:33:05 +000029PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
dgrogan@chromium.org294daf02012-11-14 05:03:50 +000030db.close()
31request = indexedDB.open(dbname, 2)
32db = event.target.result
33PASS db.version is 2
34PASS db.name is "database-basics.html"
hans@chromium.orgdccbdc62010-11-26 11:03:59 +000035PASS db.objectStoreNames is ['test123']
36PASS db.objectStoreNames.length is 1
37PASS db.objectStoreNames.contains('') is false
38PASS db.objectStoreNames.contains('test456') is false
39PASS db.objectStoreNames.contains('test123') is true
cdumez@apple.coma1fa6312016-12-01 20:33:05 +000040PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
andreip@google.com1b2e4712010-10-06 22:52:22 +000041db.createObjectStore("test456")
dgrogan@chromium.org294daf02012-11-14 05:03:50 +000042setVersionTrans = event.target.transaction
jsbell@chromium.org6b1c22e2012-05-19 23:36:46 +000043PASS setVersionTrans is non-null.
dgrogan@chromium.org294daf02012-11-14 05:03:50 +000044setVersionTrans.abort()
45PASS db.version is 1
hans@chromium.orgdccbdc62010-11-26 11:03:59 +000046PASS db.objectStoreNames is ['test123']
47PASS db.objectStoreNames.length is 1
48PASS db.objectStoreNames.contains('') is false
49PASS db.objectStoreNames.contains('test456') is false
50PASS db.objectStoreNames.contains('test123') is true
cdumez@apple.coma1fa6312016-12-01 20:33:05 +000051PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
commit-queue@webkit.org797a6c22012-01-09 21:08:32 +000052db.close()
53Now that the connection is closed, transaction creation should fail
54Expecting exception from db.transaction('test123')
55PASS Exception was thrown.
commit-queue@webkit.orgf38860d2012-06-07 21:11:36 +000056PASS code is DOMException.INVALID_STATE_ERR
57PASS ename is 'InvalidStateError'
beidson@apple.com55291222015-12-07 20:27:37 +000058Exception message: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
commit-queue@webkit.org797a6c22012-01-09 21:08:32 +000059Call twice, make sure it's harmless
60db.close()
jorlow@chromium.org6ef2aff2010-05-17 11:20:45 +000061PASS successfullyParsed is true
62
63TEST COMPLETE
andreip@google.com6d3c4e62010-09-28 18:28:21 +000064