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

Side by Side Diff: chrome/test/data/indexeddb/perf_shared.js

Issue 10836063: Add deletion test, cursor read with writeback to same store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add onblocked handler for deleteDatabase Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 window.indexedDB = window.indexedDB || window.webkitIndexedDB || 5 window.indexedDB = window.indexedDB || window.webkitIndexedDB ||
6 window.mozIndexedDB || window.msIndexedDB; 6 window.mozIndexedDB || window.msIndexedDB;
7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange; 7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
8 8
9 var automation = { 9 var automation = {
10 results: {} 10 results: {}
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 transaction.onabort = onError; 153 transaction.onabort = onError;
154 if (opt_handler) { 154 if (opt_handler) {
155 transaction.oncomplete = opt_handler; 155 transaction.oncomplete = opt_handler;
156 } 156 }
157 return transaction; 157 return transaction;
158 } 158 }
159 159
160 function deleteDatabase(name, opt_handler) { 160 function deleteDatabase(name, opt_handler) {
161 var deleteRequest = indexedDB.deleteDatabase(name); 161 var deleteRequest = indexedDB.deleteDatabase(name);
162 deleteRequest.onerror = onError; 162 deleteRequest.onerror = onError;
163 deleteRequest.onblocked = onError;
163 if (opt_handler) { 164 if (opt_handler) {
164 deleteRequest.onsuccess = opt_handler; 165 deleteRequest.onsuccess = opt_handler;
165 } 166 }
166 } 167 }
167 168
168 function getCompletionFunc(testName, startTime, onTestComplete) { 169 function getCompletionFunc(db, testName, startTime, onTestComplete) {
169 function onDeleted() { 170 function onDeleted() {
170 automation.setStatus("Deleted database."); 171 automation.setStatus("Deleted database.");
171 onTestComplete(); 172 onTestComplete();
172 } 173 }
173 return function() { 174 return function() {
174 var duration = Date.now() - startTime; 175 var duration = Date.now() - startTime;
175 // Ignore the cleanup time for this test. 176 // Ignore the cleanup time for this test.
176 automation.addResult(testName, duration); 177 automation.addResult(testName, duration);
177 automation.setStatus("Deleting database."); 178 automation.setStatus("Deleting database.");
178 // TODO(ericu): Turn on actual deletion; for now it's way too slow. 179 db.close();
179 // deleteDatabase(testName, onDeleted); 180 deleteDatabase(testName, onDeleted);
180 onTestComplete();
181 } 181 }
182 } 182 }
183 183
184 function getDisplayName(args) { 184 function getDisplayName(args) {
185 // The last arg is the completion callback the test runner tacks on. 185 // The last arg is the completion callback the test runner tacks on.
186 // TODO(ericu): Make test errors delete the database automatically. 186 // TODO(ericu): Make test errors delete the database automatically.
187 return getDisplayName.caller.name + "_" + 187 return getDisplayName.caller.name + "_" +
188 Array.prototype.slice.call(args, 0, args.length - 1).join("_"); 188 Array.prototype.slice.call(args, 0, args.length - 1).join("_");
189 } 189 }
190 190
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 var oos; 326 var oos;
327 if (outputObjectStoreName) 327 if (outputObjectStoreName)
328 oos = transaction.objectStore(outputObjectStoreName); 328 oos = transaction.objectStore(outputObjectStoreName);
329 var numReadsLeft = numReads; 329 var numReadsLeft = numReads;
330 request.onsuccess = function(event) { 330 request.onsuccess = function(event) {
331 var cursor = event.target.result; 331 var cursor = event.target.result;
332 if (cursor) { 332 if (cursor) {
333 assert(numReadsLeft); 333 assert(numReadsLeft);
334 --numReadsLeft; 334 --numReadsLeft;
335 if (oos) // Put in random order for maximum difficulty. 335 if (oos)
336 oos.put(cursor.value, Math.random()); 336 // Put in random order for maximum difficulty. We add in numKeys just
337 // in case we're writing back to the same store; this way we won't
338 // affect the number of keys available to the cursor, since we're always
339 // outside its range.
340 oos.put(cursor.value, numKeys + Math.random());
337 values.push({key: cursor.key, value: cursor.value}); 341 values.push({key: cursor.key, value: cursor.value});
338 cursor.continue(); 342 cursor.continue();
339 } else { 343 } else {
340 assert(!numReadsLeft); 344 assert(!numReadsLeft);
341 } 345 }
342 } 346 }
343 request.onerror = onError; 347 request.onerror = onError;
344 } 348 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698