| OLD | NEW |
| 1 var databaseName = "database"; | 1 var databaseName = "database"; |
| 2 var databaseVersion = 1; | 2 var databaseVersion = 1; |
| 3 | 3 |
| 4 /* Delete created databases | 4 /* Delete created databases |
| 5 * | 5 * |
| 6 * Go through each finished test, see if it has an associated database. Close | 6 * Go through each finished test, see if it has an associated database. Close |
| 7 * that and delete the database. */ | 7 * that and delete the database. */ |
| 8 add_completion_callback(function(tests) | 8 add_completion_callback(function(tests) |
| 9 { | 9 { |
| 10 for (var i in tests) | 10 for (var i in tests) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 }) | 75 }) |
| 76 rq_open.__defineSetter__("on" + evt, function(h) { | 76 rq_open.__defineSetter__("on" + evt, function(h) { |
| 77 rq_open.manually_handled[evt] = true; | 77 rq_open.manually_handled[evt] = true; |
| 78 if (!h) | 78 if (!h) |
| 79 rq_open.addEventListener(evt, function() {}); | 79 rq_open.addEventListener(evt, function() {}); |
| 80 else | 80 else |
| 81 rq_open.addEventListener(evt, test.step_func(h)); | 81 rq_open.addEventListener(evt, test.step_func(h)); |
| 82 }) | 82 }) |
| 83 } | 83 } |
| 84 | 84 |
| 85 // add a .setTest method to the DB object | 85 // add a .setTest method to the IDBOpenDBRequest object |
| 86 Object.defineProperty(rq_open, 'setTest', { | 86 Object.defineProperty(rq_open, 'setTest', { |
| 87 enumerable: false, | 87 enumerable: false, |
| 88 value: function(t) { | 88 value: function(t) { |
| 89 test = t; | 89 test = t; |
| 90 | 90 |
| 91 auto_fail("upgradeneeded", test); | 91 auto_fail("upgradeneeded", test); |
| 92 auto_fail("success", test); | 92 auto_fail("success", test); |
| 93 auto_fail("blocked", test); | 93 auto_fail("blocked", test); |
| 94 auto_fail("error", test); | 94 auto_fail("error", test); |
| 95 | 95 |
| 96 return this; | 96 return this; |
| 97 } | 97 } |
| 98 }); | 98 }); |
| 99 | 99 |
| 100 return rq_open; | 100 return rq_open; |
| 101 } | 101 } |
| 102 | 102 |
| 103 function assert_key_equals(actual, expected, description) { | 103 function assert_key_equals(actual, expected, description) { |
| 104 assert_equals(indexedDB.cmp(actual, expected), 0, description); | 104 assert_equals(indexedDB.cmp(actual, expected), 0, description); |
| 105 } | 105 } |
| 106 | 106 |
| 107 function indexeddb_test(upgrade_func, open_func, description, options) { | 107 function indexeddb_test(upgrade_func, open_func, description, options) { |
| 108 async_test(function(t) { | 108 async_test(function(t) { |
| 109 var options = Object.assign({upgrade_will_abort: false}, options); | 109 var options = Object.assign({upgrade_will_abort: false}, options); |
| 110 var dbname = document.location + '-' + t.name; | 110 var dbname = document.location + '-' + t.name; |
| 111 var del = indexedDB.deleteDatabase(dbname); | 111 var del = indexedDB.deleteDatabase(dbname); |
| 112 del.onerror = t.unreached_func('deleteDatabase should succeed'); | 112 del.onerror = t.unreached_func('deleteDatabase should succeed'); |
| 113 var open = indexedDB.open(dbname, 1); | 113 var open = indexedDB.open(dbname, 1); |
| 114 if (!options.upgrade_will_abort) { | 114 if (!options.upgrade_will_abort) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 136 function expect(t, expected) { | 136 function expect(t, expected) { |
| 137 var results = []; | 137 var results = []; |
| 138 return result => { | 138 return result => { |
| 139 results.push(result); | 139 results.push(result); |
| 140 if (results.length === expected.length) { | 140 if (results.length === expected.length) { |
| 141 assert_array_equals(results, expected); | 141 assert_array_equals(results, expected); |
| 142 t.done(); | 142 t.done(); |
| 143 } | 143 } |
| 144 }; | 144 }; |
| 145 } | 145 } |
| OLD | NEW |