Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 rq_open.addEventListener(evt, function(e) { | 55 rq_open.addEventListener(evt, function(e) { |
| 56 if (current_test !== test) { | 56 if (current_test !== test) { |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 test.step(function() { | 60 test.step(function() { |
| 61 if (!rq_open.manually_handled[evt]) { | 61 if (!rq_open.manually_handled[evt]) { |
| 62 assert_unreached("unexpected open." + evt + " event"); | 62 assert_unreached("unexpected open." + evt + " event"); |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (e.target.result + "" == "[object IDBDatabase]" && !this.db) { | 65 if (e.target.result + '' == '[object IDBDatabase]' && |
| 66 this.db = e.target.result; | 66 !this.db) { |
| 67 un this.db = e.target.result; | |
|
jsbell
2017/01/27 00:31:29
un -> editing typo?
pwnall
2017/01/27 01:23:50
Done.
Thank you :(
This somehow crawled in after I
| |
| 67 | 68 |
| 68 this.db.onerror = fail(test, "unexpected db.error"); | 69 this.db.onerror = fail(test, 'unexpected db.error'); |
| 69 this.db.onabort = fail(test, "unexpected db.abort"); | 70 this.db.onabort = fail(test, 'unexpected db.abort'); |
| 70 this.db.onversionchange = fail(test, "unexpected db.versionc hange"); | 71 this.db.onversionchange = |
| 72 fail(test, 'unexpected db.versionchange'); | |
| 71 } | 73 } |
| 72 }) | 74 }) |
| 73 }) | 75 }) |
| 74 rq_open.__defineSetter__("on" + evt, function(h) { | 76 rq_open.__defineSetter__("on" + evt, function(h) { |
| 75 rq_open.manually_handled[evt] = true; | 77 rq_open.manually_handled[evt] = true; |
| 76 if (!h) | 78 if (!h) |
| 77 rq_open.addEventListener(evt, function() {}); | 79 rq_open.addEventListener(evt, function() {}); |
| 78 else | 80 else |
| 79 rq_open.addEventListener(evt, test.step_func(h)); | 81 rq_open.addEventListener(evt, test.step_func(h)); |
| 80 }) | 82 }) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 95 } | 97 } |
| 96 }); | 98 }); |
| 97 | 99 |
| 98 return rq_open; | 100 return rq_open; |
| 99 } | 101 } |
| 100 | 102 |
| 101 function assert_key_equals(actual, expected, description) { | 103 function assert_key_equals(actual, expected, description) { |
| 102 assert_equals(indexedDB.cmp(actual, expected), 0, description); | 104 assert_equals(indexedDB.cmp(actual, expected), 0, description); |
| 103 } | 105 } |
| 104 | 106 |
| 105 function indexeddb_test(upgrade_func, open_func, description) { | 107 function indexeddb_test(upgrade_func, open_func, description, options) { |
| 106 async_test(function(t) { | 108 async_test(function(t) { |
| 107 var dbname = document.location + '-' + t.name; | 109 var dbname = document.location + '-' + t.name; |
| 108 var del = indexedDB.deleteDatabase(dbname); | 110 var del = indexedDB.deleteDatabase(dbname); |
| 109 del.onerror = t.unreached_func('deleteDatabase should succeed'); | 111 del.onerror = t.unreached_func('deleteDatabase should succeed'); |
| 110 var open = indexedDB.open(dbname, 1); | 112 var open = indexedDB.open(dbname, 1); |
| 111 open.onerror = t.unreached_func('open should succeed'); | 113 if (!(options && options.will_abort)) { |
|
jsbell
2017/01/27 00:31:29
Aside: one nice way to handle an options argument
pwnall
2017/01/27 01:23:49
Done.
I didn't know this pattern. Thank you very m
| |
| 112 open.onupgradeneeded = t.step_func(function() { | 114 open.onsuccess = t.unreached_func('open should not succeed'); |
| 113 var db = open.result; | 115 } else { |
| 114 var tx = open.transaction; | 116 open.onerror = t.unreached_func('open should succeed'); |
| 115 upgrade_func(t, db, tx); | 117 } |
| 116 }); | 118 open.onupgradeneeded = t.step_func(function() { |
| 117 open.onsuccess = t.step_func(function() { | 119 var db = open.result; |
| 118 var db = open.result; | 120 var tx = open.transaction; |
| 119 if (open_func) | 121 var old_abort = tx.abort; |
| 120 open_func(t, db); | 122 tx.abort = function() { |
|
jsbell
2017/01/27 00:31:29
we don't want to monkey patch here any more, do we
pwnall
2017/01/27 01:23:50
Done.
Sorry for the carelessness :(
| |
| 121 }); | 123 open.onerror = null; |
| 122 }, description); | 124 old_abort.call(tx); |
| 125 }; | |
| 126 upgrade_func(t, db, tx); | |
| 127 }); | |
| 128 open.onsuccess = t.step_func(function() { | |
| 129 var db = open.result; | |
| 130 if (open_func) | |
| 131 open_func(t, db); | |
| 132 }); | |
| 133 }, description); | |
| 123 } | 134 } |
| OLD | NEW |