| OLD | NEW |
| 1 if (this.importScripts) { | 1 if (this.importScripts) { |
| 2 importScripts('../../../resources/testharness.js'); | 2 importScripts('../../../resources/testharness.js'); |
| 3 importScripts('generic-idb-operations.js'); | 3 importScripts('generic-idb-operations.js'); |
| 4 } | 4 } |
| 5 | 5 |
| 6 async_test(function(t) { | 6 async_test(function(t) { |
| 7 var dbname = location.pathname + ' - ' + 'empty transaction'; | 7 var dbname = location.pathname + ' - ' + 'empty transaction'; |
| 8 var openRequest = indexedDB.open(dbname); | 8 var openRequest = indexedDB.open(dbname); |
| 9 var callback_count = 0; | 9 var callback_count = 0; |
| 10 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), {oper
ationTypes: ['put']}); | 10 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), {oper
ationTypes: ['put']}); |
| 11 | 11 |
| 12 openRequest.onupgradeneeded = t.step_func(function() { | 12 openRequest.onupgradeneeded = t.step_func(function() { |
| 13 createDatabase(openRequest.result, ['store']); | 13 openRequest.result.createObjectStore('store'); |
| 14 }); | 14 }); |
| 15 openRequest.onsuccess = t.step_func(function() { | 15 openRequest.onsuccess = t.step_func(function() { |
| 16 var db = openRequest.result; | 16 var db = openRequest.result; |
| 17 var tx1 = db.transaction('store', 'readwrite'); | 17 var tx1 = db.transaction('store', 'readwrite'); |
| 18 var tx2 = db.transaction('store', 'readwrite'); | 18 var tx2 = db.transaction('store', 'readwrite'); |
| 19 obs.observe(db, tx1); | 19 obs.observe(db, tx1); |
| 20 tx2.objectStore('store').put(1, 1); | 20 tx2.objectStore('store').put(1, 1); |
| 21 tx1.oncomplete = t.step_func(function() { | 21 tx1.oncomplete = t.step_func(function() { |
| 22 countCallbacks(callback_count, 0); | 22 countCallbacks(callback_count, 0); |
| 23 }); | 23 }); |
| 24 tx2.oncomplete = t.step_func(function() { | 24 tx2.oncomplete = t.step_func(function() { |
| 25 countCallbacks(callback_count, 1); | 25 countCallbacks(callback_count, 1); |
| 26 t.done(); | 26 t.done(); |
| 27 }); | 27 }); |
| 28 tx1.onerror = t.unreached_func('transaction should not fail'); | 28 tx1.onerror = t.unreached_func('transaction should not fail'); |
| 29 tx2.onerror = t.unreached_func('transaction should not fail'); | 29 tx2.onerror = t.unreached_func('transaction should not fail'); |
| 30 }); | 30 }); |
| 31 }, 'Registering observe call with empty transaction'); | 31 }, 'Registering observe call with empty transaction'); |
| 32 | 32 |
| 33 async_test(function(t) { | 33 async_test(function(t) { |
| 34 var dbname = location.pathname + ' - ' + 'observer in version change'; | 34 var dbname = location.pathname + ' - ' + 'observer in version change'; |
| 35 var openRequest = indexedDB.open(dbname); | 35 var openRequest = indexedDB.open(dbname); |
| 36 var callback_count = 0; | 36 var callback_count = 0; |
| 37 var obs; | 37 var obs; |
| 38 openRequest.onupgradeneeded = t.step_func(function() { | 38 openRequest.onupgradeneeded = t.step_func(function() { |
| 39 createDatabase(openRequest.result, ['store']); | 39 openRequest.result.createObjectStore('store'); |
| 40 obs = new IDBObserver(t.step_func(function(changes) { callback_count++; })
, { operationTypes: ['put'] }); | 40 obs = new IDBObserver(t.step_func(function(changes) { callback_count++; })
, { operationTypes: ['put'] }); |
| 41 }); | 41 }); |
| 42 openRequest.onsuccess = t.step_func(function() { | 42 openRequest.onsuccess = t.step_func(function() { |
| 43 var db = openRequest.result; | 43 var db = openRequest.result; |
| 44 var tx1 = db.transaction('store', 'readwrite'); | 44 var tx1 = db.transaction('store', 'readwrite'); |
| 45 var tx2 = db.transaction('store', 'readwrite'); | 45 var tx2 = db.transaction('store', 'readwrite'); |
| 46 tx1.objectStore('store').get(1); | 46 tx1.objectStore('store').get(1); |
| 47 tx2.objectStore('store').put(1, 1); | 47 tx2.objectStore('store').put(1, 1); |
| 48 obs.observe(db, tx1); | 48 obs.observe(db, tx1); |
| 49 tx1.oncomplete = t.step_func(function() { | 49 tx1.oncomplete = t.step_func(function() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 79 tx.onerror = t.unreached_func('transaction should not fail'); | 79 tx.onerror = t.unreached_func('transaction should not fail'); |
| 80 }); | 80 }); |
| 81 }, 'Observe call during version change ignored'); | 81 }, 'Observe call during version change ignored'); |
| 82 | 82 |
| 83 async_test(function(t) { | 83 async_test(function(t) { |
| 84 var dbname = location.pathname + ' - ' + 'abort associated transaction'; | 84 var dbname = location.pathname + ' - ' + 'abort associated transaction'; |
| 85 var openRequest = indexedDB.open(dbname); | 85 var openRequest = indexedDB.open(dbname); |
| 86 var callback_count = 0; | 86 var callback_count = 0; |
| 87 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), { ope
rationTypes: ['put'] }); | 87 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), { ope
rationTypes: ['put'] }); |
| 88 openRequest.onupgradeneeded = t.step_func(function() { | 88 openRequest.onupgradeneeded = t.step_func(function() { |
| 89 createDatabase(openRequest.result, ['store']); | 89 openRequest.result.createObjectStore('store'); |
| 90 }); | 90 }); |
| 91 openRequest.onsuccess = t.step_func(function() { | 91 openRequest.onsuccess = t.step_func(function() { |
| 92 var db = openRequest.result; | 92 var db = openRequest.result; |
| 93 var tx1 = db.transaction('store', 'readwrite'); | 93 var tx1 = db.transaction('store', 'readwrite'); |
| 94 var tx2 = db.transaction('store', 'readwrite'); | 94 var tx2 = db.transaction('store', 'readwrite'); |
| 95 tx1.objectStore('store').get(1); | 95 tx1.objectStore('store').get(1); |
| 96 tx2.objectStore('store').put(1, 1); | 96 tx2.objectStore('store').put(1, 1); |
| 97 obs.observe(db, tx1); | 97 obs.observe(db, tx1); |
| 98 tx1.abort(); | 98 tx1.abort(); |
| 99 | 99 |
| 100 tx1.onabort = t.step_func(function(){ | 100 tx1.onabort = t.step_func(function(){ |
| 101 countCallbacks(callback_count, 0); | 101 countCallbacks(callback_count, 0); |
| 102 }); | 102 }); |
| 103 tx1.oncomplete = t.unreached_func('transaction should not complete'); | 103 tx1.oncomplete = t.unreached_func('transaction should not complete'); |
| 104 tx2.oncomplete = t.step_func(function() { | 104 tx2.oncomplete = t.step_func(function() { |
| 105 countCallbacks(callback_count, 0); | 105 countCallbacks(callback_count, 0); |
| 106 t.done(); | 106 t.done(); |
| 107 }); | 107 }); |
| 108 tx2.onerror = t.unreached_func('transaction error should not fail'); | 108 tx2.onerror = t.unreached_func('transaction error should not fail'); |
| 109 }); | 109 }); |
| 110 }, 'Abort transaction associated with observer'); | 110 }, 'Abort transaction associated with observer'); |
| 111 | 111 |
| 112 async_test(function(t) { | 112 async_test(function(t) { |
| 113 var dbname = location.pathname + ' - ' + 'abort transaction'; | 113 var dbname = location.pathname + ' - ' + 'abort transaction'; |
| 114 var openRequest = indexedDB.open(dbname); | 114 var openRequest = indexedDB.open(dbname); |
| 115 var callback_count = 0; | 115 var callback_count = 0; |
| 116 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), { ope
rationTypes: ['put'] }); | 116 var obs = new IDBObserver(t.step_func(function() { callback_count++; }), { ope
rationTypes: ['put'] }); |
| 117 openRequest.onupgradeneeded = t.step_func(function() { | 117 openRequest.onupgradeneeded = t.step_func(function() { |
| 118 createDatabase(openRequest.result, ['store']); | 118 openRequest.result.createObjectStore('store'); |
| 119 }); | 119 }); |
| 120 openRequest.onsuccess = t.step_func(function() { | 120 openRequest.onsuccess = t.step_func(function() { |
| 121 var db = openRequest.result; | 121 var db = openRequest.result; |
| 122 var tx1 = db.transaction('store', 'readwrite'); | 122 var tx1 = db.transaction('store', 'readwrite'); |
| 123 var tx2 = db.transaction('store', 'readwrite'); | 123 var tx2 = db.transaction('store', 'readwrite'); |
| 124 var tx3 = db.transaction('store', 'readwrite'); | 124 var tx3 = db.transaction('store', 'readwrite'); |
| 125 tx1.objectStore('store').get(1); | 125 tx1.objectStore('store').get(1); |
| 126 tx2.objectStore('store').put(1, 1); | 126 tx2.objectStore('store').put(1, 1); |
| 127 tx3.objectStore('store').put(1, 1); | 127 tx3.objectStore('store').put(1, 1); |
| 128 obs.observe(db, tx1); | 128 obs.observe(db, tx1); |
| 129 tx2.abort(); | 129 tx2.abort(); |
| 130 tx1.oncomplete = t.step_func(function() { | 130 tx1.oncomplete = t.step_func(function() { |
| 131 countCallbacks(callback_count, 0); | 131 countCallbacks(callback_count, 0); |
| 132 }); | 132 }); |
| 133 tx2.oncomplete = t.unreached_func('transaction should not complete'); | 133 tx2.oncomplete = t.unreached_func('transaction should not complete'); |
| 134 tx2.onabort = t.step_func(function() { | 134 tx2.onabort = t.step_func(function() { |
| 135 countCallbacks(callback_count, 0); | 135 countCallbacks(callback_count, 0); |
| 136 }); | 136 }); |
| 137 tx3.oncomplete = t.step_func(function() { | 137 tx3.oncomplete = t.step_func(function() { |
| 138 countCallbacks(callback_count, 1); | 138 countCallbacks(callback_count, 1); |
| 139 t.done(); | 139 t.done(); |
| 140 }); | 140 }); |
| 141 tx1.onerror = t.unreached_func('transaction should not fail'); | 141 tx1.onerror = t.unreached_func('transaction should not fail'); |
| 142 tx3.onerror = t.unreached_func('transaction should not fail'); | 142 tx3.onerror = t.unreached_func('transaction should not fail'); |
| 143 }); | 143 }); |
| 144 }, 'Abort transaction recorded by observer'); | 144 }, 'Abort transaction recorded by observer'); |
| 145 | 145 |
| 146 done(); | 146 done(); |
| OLD | NEW |