OLD | NEW |
1 if (this.importScripts) { | 1 if (this.importScripts) { |
2 importScripts('../../../resources/testharness.js'); | 2 importScripts('../../../resources/testharness.js'); |
3 } | 3 } |
4 | 4 |
5 function callback(){}; | 5 function callback1(changes){ |
| 6 console.log('changes fired 1 ' + changes.records ); |
| 7 for(var objStore in changes.records ) { |
| 8 console.log(objStore); |
| 9 for(var i in changes.records[objStore]) { |
| 10 console.log(changes.records[objStore][i].type); |
| 11 } |
| 12 } |
| 13 }; |
6 | 14 |
7 async_test(function(t) { | 15 async_test(function(t) { |
8 var description = 'observer addition and removal test'; | 16 var description = 'observer changes test'; |
9 var dbname = location.pathname + ' - ' + description; | 17 var dbname = location.pathname + ' - ' + description; |
10 var openRequest = indexedDB.open(dbname); | 18 var openRequest = indexedDB.open(dbname); |
11 var obs1 = new IDBObserver(callback, {transaction: true, values: true}); | 19 var obs1 = new IDBObserver(callback1, {transaction: true, values: true}); |
12 var obs2 = new IDBObserver(callback, {transaction: true, values: true}); | 20 var obs2 = new IDBObserver(callback2, {transaction: true, values: true}); |
13 | |
14 openRequest.onupgradeneeded = t.step_func(function() { | 21 openRequest.onupgradeneeded = t.step_func(function() { |
15 var db = openRequest.result; | 22 var db = openRequest.result; |
16 db.createObjectStore('store'); | 23 db.createObjectStore('store'); |
17 }); | 24 }); |
18 openRequest.onsuccess = t.step_func(function() { | 25 openRequest.onsuccess = t.step_func(function() { |
19 var db = openRequest.result; | 26 var db = openRequest.result; |
20 var tx = db.transaction('store', 'readwrite'); | 27 var tx = db.transaction('store', 'readwrite'); |
| 28 obs1.observe(db, tx); |
| 29 obs1.observe(db, tx); |
| 30 obs2.observe(db, tx); |
21 var store = tx.objectStore('store'); | 31 var store = tx.objectStore('store'); |
22 var put_request = store.put(1,1); | 32 var put_request = store.put(1,1); |
23 obs1.observe(db, tx); | 33 tx.oncomplete = t.step_func(function(){ |
24 obs1.unobserve(db); | 34 var tx2 = db.transaction('store', 'readwrite'); |
25 obs1.observe(db, tx); | 35 var store2 = tx2.objectStore('store'); |
26 obs2.observe(db, tx); | 36 store2.put(2,2); |
27 tx.oncomplete = t.step_func(function(){ | 37 store2.put(3,3); |
28 obs1.unobserve(db); | 38 tx2.oncomplete = t.step_func(function(){ |
29 t.done(); | |
30 }); | |
31 }); | 39 }); |
32 }, 'observer addition and removal test'); | 40 }); |
| 41 }); |
| 42 }, 'observer changes test'); |
33 | 43 |
34 done(); | 44 done(); |
35 | 45 |
OLD | NEW |