| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>IndexedDB: object store renaming support in aborted transactions</title> | |
| 3 <link rel="help" | |
| 4 href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name"> | |
| 5 <link rel="author" href="pwnall@chromium.org" title="Victor Costan"> | |
| 6 <script src="/resources/testharness.js"></script> | |
| 7 <script src="/resources/testharnessreport.js"></script> | |
| 8 <script src="support-promises.js"></script> | |
| 9 <script> | |
| 10 | |
| 11 promise_test(testCase => { | |
| 12 const dbName = databaseName(testCase); | |
| 13 let bookStore = null, bookStore2 = null; | |
| 14 return createDatabase(testCase, (database, transaction) => { | |
| 15 createBooksStore(testCase, database); | |
| 16 }).then(database => { | |
| 17 database.close(); | |
| 18 }).then(() => migrateDatabase(testCase, 2, (database, transaction) => { | |
| 19 bookStore = transaction.objectStore('books'); | |
| 20 bookStore.name = 'renamed_books'; | |
| 21 | |
| 22 transaction.abort(); | |
| 23 | |
| 24 assert_equals( | |
| 25 bookStore.name, 'books', | |
| 26 'IDBObjectStore.name should not reflect the rename any more ' + | |
| 27 'immediately after transaction.abort() returns'); | |
| 28 assert_array_equals( | |
| 29 database.objectStoreNames, ['books'], | |
| 30 'IDBDatabase.objectStoreNames should not reflect the rename ' + | |
| 31 'any more immediately after transaction.abort() returns'); | |
| 32 assert_array_equals( | |
| 33 transaction.objectStoreNames, ['books'], | |
| 34 'IDBTransaction.objectStoreNames should not reflect the ' + | |
| 35 'rename any more immediately after transaction.abort() returns'); | |
| 36 })).then(event => { | |
| 37 assert_equals(bookStore.name, 'books', | |
| 38 'IDBObjectStore.name should not reflect the rename any more ' + | |
| 39 'after the versionchange transaction is aborted'); | |
| 40 const request = indexedDB.open(dbName, 1); | |
| 41 return requestWatcher(testCase, request).wait_for('success'); | |
| 42 }).then(event => { | |
| 43 const database = event.target.result; | |
| 44 assert_array_equals( | |
| 45 database.objectStoreNames, ['books'], | |
| 46 'IDBDatabase.objectStoreNames should not reflect the rename ' + | |
| 47 'after the versionchange transaction is aborted'); | |
| 48 | |
| 49 const transaction = database.transaction('books', 'readonly'); | |
| 50 bookStore2 = transaction.objectStore('books'); | |
| 51 return checkStoreContents( | |
| 52 testCase, bookStore2, | |
| 53 'Aborting an object store rename transaction should not change ' + | |
| 54 "the store's records").then(() => database.close()); | |
| 55 }).then(() => { | |
| 56 assert_equals( | |
| 57 bookStore.name, 'books', | |
| 58 'IDBObjectStore used in aborted rename transaction should not ' + | |
| 59 'reflect the rename after the transaction is aborted'); | |
| 60 assert_equals( | |
| 61 bookStore2.name, 'books', | |
| 62 'IDBObjectStore obtained after an aborted rename transaction ' + | |
| 63 'should not reflect the rename'); | |
| 64 }); | |
| 65 }, 'IndexedDB object store rename in aborted transaction'); | |
| 66 | |
| 67 promise_test(testCase => { | |
| 68 const dbName = databaseName(testCase); | |
| 69 let notBookStore = null; | |
| 70 return createDatabase(testCase, (database, transaction) => { | |
| 71 }).then(database => { | |
| 72 database.close(); | |
| 73 }).then(() => migrateDatabase(testCase, 2, (database, transaction) => { | |
| 74 notBookStore = createNotBooksStore(testCase, database); | |
| 75 notBookStore.name = 'not_books_renamed'; | |
| 76 notBookStore.name = 'not_books_renamed_again'; | |
| 77 | |
| 78 transaction.abort(); | |
| 79 | |
| 80 assert_equals( | |
| 81 notBookStore.name, 'not_books_renamed_again', | |
| 82 'IDBObjectStore.name should reflect the last rename ' + | |
| 83 'immediately after transaction.abort() returns'); | |
| 84 assert_array_equals( | |
| 85 database.objectStoreNames, [], | |
| 86 'IDBDatabase.objectStoreNames should not reflect the creation ' + | |
| 87 'or the rename any more immediately after transaction.abort() ' + | |
| 88 'returns'); | |
| 89 assert_array_equals( | |
| 90 transaction.objectStoreNames, [], | |
| 91 'IDBTransaction.objectStoreNames should not reflect the ' + | |
| 92 'creation or the rename any more immediately after ' + | |
| 93 'transaction.abort() returns'); | |
| 94 assert_array_equals(notBookStore.indexNames, [], | |
| 95 'IDBObjectStore.indexNames for the newly created store ' + | |
| 96 'should be empty immediately after transaction.abort() ' + | |
| 97 'returns'); | |
| 98 })).then(event => { | |
| 99 assert_equals( | |
| 100 notBookStore.name, 'not_books_renamed_again', | |
| 101 'IDBObjectStore.name should reflect the last rename after the ' + | |
| 102 'versionchange transaction is aborted'); | |
| 103 assert_array_equals(notBookStore.indexNames, [], | |
| 104 'IDBObjectStore.indexNames for the newly created store ' + | |
| 105 'should be empty after the versionchange transaction is aborted ' + | |
| 106 'returns'); | |
| 107 const request = indexedDB.open(dbName, 1); | |
| 108 return requestWatcher(testCase, request).wait_for('success'); | |
| 109 }).then(event => { | |
| 110 const database = event.target.result; | |
| 111 assert_array_equals( | |
| 112 database.objectStoreNames, [], | |
| 113 'IDBDatabase.objectStoreNames should not reflect the creation or ' + | |
| 114 'the rename after the versionchange transaction is aborted'); | |
| 115 | |
| 116 database.close(); | |
| 117 }); | |
| 118 }, 'IndexedDB object store creation and rename in an aborted transaction'); | |
| 119 | |
| 120 </script> | |
| OLD | NEW |