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

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

Issue 2449563002: [IndexedDB] Add Observer Tests (Closed)
Patch Set: Finished suite coverage Created 4 years, 1 month 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
(Empty)
1 if (this.importScripts) {
2 importScripts('../../../resources/testharness.js');
3 }
4
5
6 window=this;
7 var isWorker = window.document === undefined;
8
9
10 var runActions = function() {
11 var partOneActionsDone = 0;
12 var partOneActions = 2;
13
14 var partOneActionDone = function(t) {
15 partOneActionsDone = partOneActionsDone + 1;
16 if (partOneActionsDone == partOneActions) {
17 runPartTwoActions();
18 } else if (partOneActionsDone > partOneActions) {
19 assert_unreached("Unexpected test callback.");
20 }
21 t.done();
22 }
23
24 async_test(function(t) {
25 var openRequest = indexedDB.open('observersDB1');
26
27 openRequest.onupgradeneeded = t.unreached_func('Database should be created') ;
28 openRequest.onsuccess = t.step_func(function() {
29 var db = openRequest.result;
30 var txn = db.transaction(['store1', 'store2'], 'readwrite');
31
32 var os1 = txn.objectStore('store1');
33 os1.delete(IDBKeyRange.bound('a', 'b'));
34 os1.put('c', 'a');
35
36 var os2 = txn.objectStore('store2');
37 os2.add('z', 'z');
38
39 txn.onerror = t.unreached_func('transaction should not fail');
40 txn.oncomplete = t.step_func(partOneActionDone.bind(this, t));
41 });
42 }, 'IDB Observers [Actions1]: observersDB1');
43
44 async_test(function(t) {
45 var openRequest = indexedDB.open('observersDB2');
46
47 openRequest.onupgradeneeded = t.unreached_func('Database should be created') ;
48 openRequest.onsuccess = t.step_func(function() {
49 var db = openRequest.result;
50 var txn = db.transaction(['store3', 'store4'], 'readwrite');
51
52 var os1 = txn.objectStore('store3');
53 os1.put('d', 'c');
54
55 var os2 = txn.objectStore('store4');
56 os2.add('z', 'z');
57
58 txn.onerror = t.unreached_func('transaction should not fail');
59 txn.oncomplete = t.step_func(partOneActionDone.bind(this, t));
60 });
61 }, 'IDB Observers [Actions1]: observersDB2');
62
63 var runPartTwoActions = function() {
64 async_test(function(t) {
65 var openRequest = indexedDB.open('observersDB1');
66
67 openRequest.onupgradeneeded = t.unreached_func('Database should be created ');
68 openRequest.onsuccess = t.step_func(function() {
69 var db = openRequest.result;
70 var txn = db.transaction(['store1', 'store2'], 'readwrite');
71
72 var os1 = txn.objectStore('store1');
73 os1.delete(IDBKeyRange.bound('a', 'b'));
74 os1.put('d', 'a');
75
76 var os2 = txn.objectStore('store2');
77 os2.put('a', 'z');
78
79 txn.onerror = t.unreached_func('transaction should not fail');
80 txn.oncomplete = t.step_func(t.done);
81 });
82 }, 'IDB Observers [Actions2]: observersDB1');
83
84 async_test(function(t) {
85 var openRequest = indexedDB.open('observersDB2');
86
87 openRequest.onupgradeneeded = t.unreached_func('Database should be created ');
88 openRequest.onsuccess = t.step_func(function() {
89 var db = openRequest.result;
90 var txn = db.transaction(['store3', 'store4'], 'readwrite');
91
92 var os1 = txn.objectStore('store3');
93 os1.put('e', 'c');
94
95 var os2 = txn.objectStore('store4');
96 os2.put('f', 'z');
97
98 txn.onerror = t.unreached_func('transaction should not fail');
99 txn.oncomplete = t.step_func(t.done);
100 });
101 }, 'IDB Observers [Actions2]: observersDB2');
102 }
103 }
104
105 if (isWorker) {
106 runActions();
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698