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 Exception message: Failed to execute 'transaction' on 'IDBDatabase': The databas
e connection is closing. |
24 "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." |
25 transaction.oncomplete = testIDBDatabaseName | 25 transaction.oncomplete = testIDBDatabaseName |
26 | 26 |
27 IDBDatabase.name: | 27 IDBDatabase.name: |
28 "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." |
29 PASS connection.name is dbname | 29 PASS connection.name is dbname |
30 | 30 |
31 IDBDatabase.objectStoreNames: | 31 IDBDatabase.objectStoreNames: |
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 "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." |
33 request = indexedDB.open(dbname, 2) | 33 request = indexedDB.open(dbname, 2) |
34 version_change_connection = request.result | 34 version_change_connection = request.result |
35 version_change_connection.createObjectStore('new_store') | 35 version_change_connection.createObjectStore('new_store') |
36 PASS version_change_connection.objectStoreNames.contains('new_store') is true | 36 PASS version_change_connection.objectStoreNames.contains('new_store') is true |
37 PASS connection.objectStoreNames.contains('new_store') is false | 37 PASS connection.objectStoreNames.contains('new_store') is false |
38 version_change_connection.close() | 38 version_change_connection.close() |
39 | 39 |
40 IDBDatabase.transaction(): | 40 IDBDatabase.transaction(): |
41 "...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." |
42 Expecting exception from connection.transaction('store') | 42 Expecting exception from connection.transaction('store') |
43 PASS Exception was thrown. | 43 PASS Exception was thrown. |
44 PASS code is DOMException.INVALID_STATE_ERR | 44 PASS code is DOMException.INVALID_STATE_ERR |
45 PASS ename is 'InvalidStateError' | 45 PASS ename is 'InvalidStateError' |
46 Exception message: The database connection is closing. | 46 Exception message: Failed to execute 'transaction' on 'IDBDatabase': The databas
e connection is closing. |
47 | 47 |
48 "versionchange" transaction steps: | 48 "versionchange" transaction steps: |
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." | 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." |
50 request = indexedDB.open(dbname) | 50 request = indexedDB.open(dbname) |
51 connection = request.result | 51 connection = request.result |
52 versionChangeWasFired = false | 52 versionChangeWasFired = false |
53 connection.onversionchange = function () { versionChangeWasFired = true; } | 53 connection.onversionchange = function () { versionChangeWasFired = true; } |
54 transaction = connection.transaction('store') | 54 transaction = connection.transaction('store') |
55 connection.close() | 55 connection.close() |
56 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... |
69 transaction = connection.transaction('store') | 69 transaction = connection.transaction('store') |
70 connection.close() | 70 connection.close() |
71 closePending is set, but active transaction will keep connection from closing | 71 closePending is set, but active transaction will keep connection from closing |
72 request = indexedDB.deleteDatabase(dbname) | 72 request = indexedDB.deleteDatabase(dbname) |
73 'blocked' event fired, letting transaction complete and connection close | 73 'blocked' event fired, letting transaction complete and connection close |
74 PASS versionChangeWasFired is false | 74 PASS versionChangeWasFired is false |
75 PASS successfullyParsed is true | 75 PASS successfullyParsed is true |
76 | 76 |
77 TEST COMPLETE | 77 TEST COMPLETE |
78 | 78 |
OLD | NEW |