OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>IndexedDB: aborting transactions reverts object store metadata</title> |
| 3 <script src='../../resources/testharness.js'></script> |
| 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#abort-transaction"> |
| 5 <link rel="author" href="pwnall@chromium.org" title="Victor Costan"> |
| 6 <script src='../../resources/testharnessreport.js'></script> |
| 7 <script src='resources/rename-common.js'></script> |
| 8 <script> |
| 9 |
| 10 promise_test(testCase => { |
| 11 let store = null, migrationTransaction = null, migrationDatabase = null; |
| 12 return createDatabase(testCase, (database, transaction) => { |
| 13 createBooksStore(testCase, database); |
| 14 }).then(database => { |
| 15 database.close(); |
| 16 }).then(() => migrateDatabase(testCase, 2, (database, transaction) => { |
| 17 store = createNotBooksStore(testCase, database); |
| 18 migrationDatabase = database; |
| 19 migrationTransaction = transaction; |
| 20 assert_array_equals( |
| 21 database.objectStoreNames, ['books', 'not_books'], |
| 22 'IDBDatabase.objectStoreNames should include a newly created ' + |
| 23 'store before the transaction is aborted'); |
| 24 assert_array_equals( |
| 25 transaction.objectStoreNames, ['books', 'not_books'], |
| 26 'IDBTransaction.objectStoreNames should include a newly created ' + |
| 27 'store before the transaction is aborted'); |
| 28 |
| 29 transaction.abort(); |
| 30 assert_throws( |
| 31 'InvalidStateError', () => store.get('query'), |
| 32 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 33 'that the store is marked for deletion, immediately after ' + |
| 34 'IDBTransaction.abort() returns'); |
| 35 assert_array_equals( |
| 36 transaction.objectStoreNames, ['books'], |
| 37 'IDBTransaction.objectStoreNames should stop including the newly ' + |
| 38 'created store immediately after IDBTransaction.abort() returns'); |
| 39 assert_array_equals( |
| 40 database.objectStoreNames, ['books'], |
| 41 'IDBDatabase.objectStoreNames should stop including the newly ' + |
| 42 'created store immediately after IDBTransaction.abort() returns'); |
| 43 })).then(() => { |
| 44 assert_throws( |
| 45 'InvalidStateError', () => store.get('query'), |
| 46 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 47 'that the store is marked for deletion, after the transaction is ' + |
| 48 'aborted'); |
| 49 assert_array_equals( |
| 50 migrationDatabase.objectStoreNames, ['books'], |
| 51 'IDBDatabase.objectStoreNames should stop including the newly ' + |
| 52 'created store after the transaction is aborted'); |
| 53 assert_array_equals( |
| 54 migrationTransaction.objectStoreNames, ['books'], |
| 55 'IDBTransaction.objectStoreNames should stop including the newly ' + |
| 56 'created store after the transaction is aborted'); |
| 57 }); |
| 58 }, 'Created stores get marked as deleted after their transaction aborts'); |
| 59 |
| 60 promise_test(testCase => { |
| 61 let store = null, migrationTransaction = null, migrationDatabase = null; |
| 62 return createDatabase(testCase, (database, transaction) => { |
| 63 createBooksStore(testCase, database); |
| 64 createNotBooksStore(testCase, database); |
| 65 }).then(database => { |
| 66 database.close(); |
| 67 }).then(() => migrateDatabase(testCase, 2, (database, transaction) => { |
| 68 migrationDatabase = database; |
| 69 migrationTransaction = transaction; |
| 70 store = transaction.objectStore('not_books'); |
| 71 |
| 72 database.deleteObjectStore('not_books'); |
| 73 assert_throws( |
| 74 'InvalidStateError', () => store.get('query'), |
| 75 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 76 'that the store is marked for deletion, immediately after ' + |
| 77 'IDBDatabase.deleteObjectStore() returns'); |
| 78 assert_array_equals( |
| 79 transaction.objectStoreNames, ['books'], |
| 80 'IDBTransaction.objectStoreNames should stop including the ' + |
| 81 'deleted store immediately after IDBDatabase.deleteObjectStore() ' + |
| 82 'returns'); |
| 83 assert_array_equals( |
| 84 database.objectStoreNames, ['books'], |
| 85 'IDBDatabase.objectStoreNames should stop including the newly ' + |
| 86 'created store immediately after IDBDatabase.deleteObjectStore() ' + |
| 87 'returns'); |
| 88 |
| 89 transaction.abort(); |
| 90 assert_throws( |
| 91 'TransactionInactiveError', () => store.get('query'), |
| 92 'IDBObjectStore.get should throw TransactionInactiveError, ' + |
| 93 'indicating that the store is no longer marked for deletion, ' + |
| 94 'immediately after IDBTransaction.abort() returns'); |
| 95 assert_array_equals( |
| 96 database.objectStoreNames, ['books', 'not_books'], |
| 97 'IDBDatabase.objectStoreNames should include the deleted store ' + |
| 98 'store immediately after IDBTransaction.abort() returns'); |
| 99 assert_array_equals( |
| 100 transaction.objectStoreNames, ['books', 'not_books'], |
| 101 'IDBTransaction.objectStoreNames should include the deleted ' + |
| 102 'store immediately after IDBTransaction.abort() returns'); |
| 103 })).then(() => { |
| 104 assert_throws( |
| 105 'TransactionInactiveError', () => store.get('query'), |
| 106 'IDBObjectStore.get should throw TransactionInactiveError, ' + |
| 107 'indicating that the store is no longer marked for deletion, ' + |
| 108 'after the transaction is aborted'); |
| 109 assert_array_equals( |
| 110 migrationDatabase.objectStoreNames, ['books', 'not_books'], |
| 111 'IDBDatabase.objectStoreNames should include the previously ' + |
| 112 'deleted store after the transaction is aborted'); |
| 113 assert_array_equals( |
| 114 migrationTransaction.objectStoreNames, ['books', 'not_books'], |
| 115 'IDBTransaction.objectStoreNames should include the previously ' + |
| 116 'deleted store after the transaction is aborted'); |
| 117 }); |
| 118 }, 'Deleted stores get marked as not-deleted after the transaction aborts'); |
| 119 |
| 120 promise_test(testCase => { |
| 121 let store = null, migrationTransaction = null, migrationDatabase = null; |
| 122 return createDatabase(testCase, (database, transaction) => { |
| 123 createBooksStore(testCase, database); |
| 124 }).then(database => { |
| 125 database.close(); |
| 126 }).then(() => migrateDatabase(testCase, 2, (database, transaction) => { |
| 127 store = createNotBooksStore(testCase, database); |
| 128 migrationDatabase = database; |
| 129 migrationTransaction = transaction; |
| 130 assert_array_equals( |
| 131 database.objectStoreNames, ['books', 'not_books'], |
| 132 'IDBDatabase.objectStoreNames should include a newly created ' + |
| 133 'store before the transaction is aborted'); |
| 134 assert_array_equals( |
| 135 transaction.objectStoreNames, ['books', 'not_books'], |
| 136 'IDBTransaction.objectStoreNames should include a newly created ' + |
| 137 'store before the transaction is aborted'); |
| 138 |
| 139 database.deleteObjectStore('not_books'); |
| 140 assert_throws( |
| 141 'InvalidStateError', () => store.get('query'), |
| 142 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 143 'that the store is marked for deletion, immediately after ' + |
| 144 'IDBDatabase.deleteObjectStore() returns'); |
| 145 assert_array_equals( |
| 146 transaction.objectStoreNames, ['books'], |
| 147 'IDBTransaction.objectStoreNames should stop including the ' + |
| 148 'deleted store immediately after IDBDatabase.deleteObjectStore() ' + |
| 149 'returns'); |
| 150 assert_array_equals( |
| 151 database.objectStoreNames, ['books'], |
| 152 'IDBDatabase.objectStoreNames should stop including the newly ' + |
| 153 'created store immediately after IDBDatabase.deleteObjectStore() ' + |
| 154 'returns'); |
| 155 |
| 156 transaction.abort(); |
| 157 assert_throws( |
| 158 'InvalidStateError', () => store.get('query'), |
| 159 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 160 'that the store is still marked for deletion, immediately after ' + |
| 161 'IDBTransaction.abort() returns'); |
| 162 assert_array_equals( |
| 163 transaction.objectStoreNames, ['books'], |
| 164 'IDBTransaction.objectStoreNames should not include the newly ' + |
| 165 'created store immediately after IDBTransaction.abort() returns'); |
| 166 assert_array_equals( |
| 167 database.objectStoreNames, ['books'], |
| 168 'IDBDatabase.objectStoreNames should not include the newly ' + |
| 169 'created store immediately after IDBTransaction.abort() returns'); |
| 170 })).then(() => { |
| 171 assert_throws( |
| 172 'InvalidStateError', () => store.get('query'), |
| 173 'IDBObjectStore.get should throw InvalidStateError, indicating ' + |
| 174 'that the store is still marked for deletion, after the ' + |
| 175 'transaction is aborted'); |
| 176 assert_array_equals( |
| 177 migrationDatabase.objectStoreNames, ['books'], |
| 178 'IDBDatabase.objectStoreNames should not include the newly ' + |
| 179 'created store after the transaction is aborted'); |
| 180 assert_array_equals( |
| 181 migrationTransaction.objectStoreNames, ['books'], |
| 182 'IDBTransaction.objectStoreNames should not include the newly ' + |
| 183 'created store after the transaction is aborted'); |
| 184 }); |
| 185 }, 'Created+deleted stores are still marked as deleted after their ' + |
| 186 'transaction aborts'); |
| 187 |
| 188 </script> |
OLD | NEW |