Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer.js

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: Propogating Changes to Renderer Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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[0].type );
7 };
8
9 function callback2(changes){
10 console.log('changes fired 2 ' + changes.records[0].type );
11 };
6 12
7 async_test(function(t) { 13 async_test(function(t) {
8 var description = 'observer addition and removal test'; 14 var description = 'observer addition and removal test';
9 var dbname = location.pathname + ' - ' + description; 15 var dbname = location.pathname + ' - ' + description;
10 var openRequest = indexedDB.open(dbname); 16 var openRequest = indexedDB.open(dbname);
11 var obs1 = new IDBObserver(callback, {transaction: true, values: true}); 17 var obs1 = new IDBObserver(callback1, {transaction: true, values: true});
12 var obs2 = new IDBObserver(callback, {transaction: true, values: true}); 18 var obs2 = new IDBObserver(callback2, {transaction: true, values: true});
13
14 openRequest.onupgradeneeded = t.step_func(function() { 19 openRequest.onupgradeneeded = t.step_func(function() {
15 var db = openRequest.result; 20 var db = openRequest.result;
16 db.createObjectStore('store'); 21 db.createObjectStore('store');
17 }); 22 });
18 openRequest.onsuccess = t.step_func(function() { 23 openRequest.onsuccess = t.step_func(function() {
19 var db = openRequest.result; 24 var db = openRequest.result;
20 var tx = db.transaction('store', 'readwrite'); 25 var tx = db.transaction('store', 'readwrite');
26 obs1.observe(db, tx);
27 obs1.observe(db, tx);
28 obs2.observe(db, tx);
21 var store = tx.objectStore('store'); 29 var store = tx.objectStore('store');
22 var put_request = store.put(1,1); 30 var put_request = store.put(1,1);
23 obs1.observe(db, tx); 31 tx.oncomplete = t.step_func(function(){
24 obs1.unobserve(db); 32 console.log('tx1 complete');
25 obs1.observe(db, tx); 33 var tx2 = db.transaction('store', 'readwrite');
26 obs2.observe(db, tx); 34 var store2 = tx2.objectStore('store');
27 tx.oncomplete = t.step_func(function(){ 35 var put_request2 = store2.put(2,2);
28 obs1.unobserve(db); 36 tx2.oncomplete = t.step_func(function(){
29 t.done(); 37 console.log('tx2 complete');
30 });
31 }); 38 });
32 }, 'observer addition and removal test'); 39 });
40 });
41 }, 'observer changes test');
33 42
34 done(); 43 done();
35 44
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698