OLD | NEW |
1 Test IndexedDB IDBDatabase internal closePending flag | 1 Test IndexedDB IDBDatabase internal closePending flag |
2 | 2 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". |
4 | 4 |
5 | 5 |
6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; |
7 | 7 |
8 dbname = "database-closepending-flag.html" | 8 dbname = "database-closepending-flag.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
11 store = connection.createObjectStore('store') | 11 store = connection.createObjectStore('store') |
12 | 12 |
13 First, verify that the database connection is not closed: | 13 First, verify that the database connection is not closed: |
14 PASS transaction = connection.transaction('store') did not throw exception. | 14 PASS transaction = connection.transaction('store') did not throw exception. |
15 | 15 |
16 Database closing steps | 16 Database closing steps |
17 "1. Set the internal closePending flag of connection to true." | 17 "1. Set the internal closePending flag of connection to true." |
18 connection.close() | 18 connection.close() |
19 Expecting exception from connection.transaction('store') | 19 Expecting exception from connection.transaction('store') |
20 PASS Exception was thrown. | 20 PASS Exception was thrown. |
21 PASS code is DOMException.INVALID_STATE_ERR | 21 PASS code is DOMException.INVALID_STATE_ERR |
22 PASS ename is 'InvalidStateError' | 22 PASS ename is 'InvalidStateError' |
| 23 Exception message: The database connection is closing. |
23 "2. Wait for all transactions created using connection to complete. Once they ar
e complete, connection is closed." | 24 "2. Wait for all transactions created using connection to complete. Once they ar
e complete, connection is closed." |
24 transaction.oncomplete = testIDBDatabaseName | 25 transaction.oncomplete = testIDBDatabaseName |
25 | 26 |
26 IDBDatabase.name: | 27 IDBDatabase.name: |
27 "The function must return this name even if the closePending flag is set on the
connection." | 28 "The function must return this name even if the closePending flag is set on the
connection." |
28 PASS connection.name is dbname | 29 PASS connection.name is dbname |
29 | 30 |
30 IDBDatabase.objectStoreNames: | 31 IDBDatabase.objectStoreNames: |
31 "Once the closePending flag is set on the connection, this function must return
a snapshot of the list of names of the object stores taken at the time when the
close method was called." | 32 "Once the closePending flag is set on the connection, this function must return
a snapshot of the list of names of the object stores taken at the time when the
close method was called." |
32 request = indexedDB.open(dbname, 2) | 33 request = indexedDB.open(dbname, 2) |
33 version_change_connection = request.result | 34 version_change_connection = request.result |
34 version_change_connection.createObjectStore('new_store') | 35 version_change_connection.createObjectStore('new_store') |
35 PASS version_change_connection.objectStoreNames.contains('new_store') is true | 36 PASS version_change_connection.objectStoreNames.contains('new_store') is true |
36 PASS connection.objectStoreNames.contains('new_store') is false | 37 PASS connection.objectStoreNames.contains('new_store') is false |
37 version_change_connection.close() | 38 version_change_connection.close() |
38 | 39 |
39 IDBDatabase.transaction(): | 40 IDBDatabase.transaction(): |
40 "...if this method is called on a IDBDatabase instance where the closePending fl
ag is set, a InvalidStateError exception must be thrown." | 41 "...if this method is called on a IDBDatabase instance where the closePending fl
ag is set, a InvalidStateError exception must be thrown." |
41 Expecting exception from connection.transaction('store') | 42 Expecting exception from connection.transaction('store') |
42 PASS Exception was thrown. | 43 PASS Exception was thrown. |
43 PASS code is DOMException.INVALID_STATE_ERR | 44 PASS code is DOMException.INVALID_STATE_ERR |
44 PASS ename is 'InvalidStateError' | 45 PASS ename is 'InvalidStateError' |
| 46 Exception message: The database connection is closing. |
45 | 47 |
46 "versionchange" transaction steps: | 48 "versionchange" transaction steps: |
47 "Fire a versionchange event at each object in openDatabases that is open. The ev
ent must not be fired on objects which has the closePending flag set." | 49 "Fire a versionchange event at each object in openDatabases that is open. The ev
ent must not be fired on objects which has the closePending flag set." |
48 request = indexedDB.open(dbname) | 50 request = indexedDB.open(dbname) |
49 connection = request.result | 51 connection = request.result |
50 versionChangeWasFired = false | 52 versionChangeWasFired = false |
51 connection.onversionchange = function () { versionChangeWasFired = true; } | 53 connection.onversionchange = function () { versionChangeWasFired = true; } |
52 transaction = connection.transaction('store') | 54 transaction = connection.transaction('store') |
53 connection.close() | 55 connection.close() |
54 closePending is set, but active transaction will keep connection from closing | 56 closePending is set, but active transaction will keep connection from closing |
(...skipping 12 matching lines...) Expand all Loading... |
67 transaction = connection.transaction('store') | 69 transaction = connection.transaction('store') |
68 connection.close() | 70 connection.close() |
69 closePending is set, but active transaction will keep connection from closing | 71 closePending is set, but active transaction will keep connection from closing |
70 request = indexedDB.deleteDatabase(dbname) | 72 request = indexedDB.deleteDatabase(dbname) |
71 'blocked' event fired, letting transaction complete and connection close | 73 'blocked' event fired, letting transaction complete and connection close |
72 PASS versionChangeWasFired is false | 74 PASS versionChangeWasFired is false |
73 PASS successfullyParsed is true | 75 PASS successfullyParsed is true |
74 | 76 |
75 TEST COMPLETE | 77 TEST COMPLETE |
76 | 78 |
OLD | NEW |