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

Side by Side Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js

Issue 2415203002: Indexed DB: More exception precedence tests (Closed)
Patch Set: Created 4 years, 2 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 function indexeddb_test(upgrade_func, body_func, description) { 1 function indexeddb_test(upgrade_func, body_func, description) {
2 async_test(function(t) { 2 async_test(function(t) {
3 var dbName = 'db' + self.location.pathname + '-' + description; 3 var dbName = 'db' + self.location.pathname + '-' + description;
4 var delete_request = indexedDB.deleteDatabase(dbName); 4 var delete_request = indexedDB.deleteDatabase(dbName);
5 delete_request.onerror = t.unreached_func('deleteDatabase should not fai l'); 5 delete_request.onerror = t.unreached_func('deleteDatabase should not fai l');
6 delete_request.onsuccess = t.step_func(function(e) { 6 delete_request.onsuccess = t.step_func(function(e) {
7 var open_request = indexedDB.open(dbName); 7 var open_request = indexedDB.open(dbName);
8 open_request.onerror = t.unreached_func('open should not fail'); 8 open_request.onerror = t.unreached_func('open should not fail');
9 open_request.onupgradeneeded = t.step_func(function(e) { 9 open_request.onupgradeneeded = t.step_func(function(e) {
10 upgrade_func(t, open_request.result); 10 upgrade_func(t, open_request.result);
pwnall 2016/10/14 07:57:05 This is where I added the open_request.transaction
jsbell 2016/10/17 19:42:04 Done.
11 }); 11 });
12 open_request.onsuccess = t.step_func(function(e) { 12 open_request.onsuccess = t.step_func(function(e) {
13 body_func(t, open_request.result); 13 body_func(t, open_request.result);
14 }); 14 });
15 }); 15 });
16 }, description); 16 }, description);
17 } 17 }
18 18
19 function assert_key_equals(a, b, message) { 19 function assert_key_equals(a, b, message) {
20 assert_equals(indexedDB.cmp(a, b), 0, message); 20 assert_equals(indexedDB.cmp(a, b), 0, message);
21 } 21 }
22 22
23 // Call with a Test and an array of expected results in order. Returns 23 // Call with a Test and an array of expected results in order. Returns
24 // a function; call the function when a result arrives and when the 24 // a function; call the function when a result arrives and when the
25 // expected number appear the order will be asserted and test 25 // expected number appear the order will be asserted and test
26 // completed. 26 // completed.
27 function expect(t, expected) { 27 function expect(t, expected) {
28 var results = []; 28 var results = [];
29 return result => { 29 return result => {
30 results.push(result); 30 results.push(result);
31 if (results.length === expected.length) { 31 if (results.length === expected.length) {
32 assert_array_equals(results, expected); 32 assert_array_equals(results, expected);
33 t.done(); 33 t.done();
34 } 34 }
35 }; 35 };
36 } 36 }
37
38 // Pins the transaction associated with the given store open by
39 // issuing a chain of get(0) requests. Returns a function to call to
40 // stop the requests and let the transaction complete. Useful when you
41 // need to ensure a transaction is alive across other asynchronous
42 // operations (e.g. setTimeout)
43 function pin_transaction(store) {
pwnall 2016/10/14 07:57:05 The docs do state that the point of it is to keep
jsbell 2016/10/17 19:42:04 Agreed, but...
44 let finish = false;
45 (function spin() {
46 if (finish)
47 return;
48 store.get(0).onsuccess = spin;
49 }());
50 return () => {
51 finish = true;
52 };
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698