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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/support.js

Issue 2659513002: Upstream an assortment of IndexedDB tests to WPT. (Closed)
Patch Set: Rebased MANIFEST.json Created 3 years, 10 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 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
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 this.db = e.target.result;
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
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 options = Object.assign({upgrade_will_abort: false}, options);
108 var del = indexedDB.deleteDatabase(dbname); 110 var dbname = document.location + '-' + t.name;
109 del.onerror = t.unreached_func('deleteDatabase should succeed'); 111 var del = indexedDB.deleteDatabase(dbname);
110 var open = indexedDB.open(dbname, 1); 112 del.onerror = t.unreached_func('deleteDatabase should succeed');
111 open.onerror = t.unreached_func('open should succeed'); 113 var open = indexedDB.open(dbname, 1);
112 open.onupgradeneeded = t.step_func(function() { 114 if (!options.upgrade_will_abort) {
113 var db = open.result; 115 open.onsuccess = t.unreached_func('open should not succeed');
114 var tx = open.transaction; 116 } else {
115 upgrade_func(t, db, tx); 117 open.onerror = t.unreached_func('open should succeed');
116 }); 118 }
117 open.onsuccess = t.step_func(function() { 119 open.onupgradeneeded = t.step_func(function() {
118 var db = open.result; 120 var db = open.result;
119 if (open_func) 121 var tx = open.transaction;
120 open_func(t, db); 122 upgrade_func(t, db, tx);
121 }); 123 });
122 }, description); 124 open.onsuccess = t.step_func(function() {
125 var db = open.result;
126 if (open_func)
127 open_func(t, db);
128 });
129 }, description);
123 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698