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

Unified Diff: chrome/test/data/indexeddb/perf_shared.js

Issue 10790041: Add IDB perf tests for random read, with and without an index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix index creation and db deletion [but comment out deletion]. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | chrome/test/data/indexeddb/perf_test.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/indexeddb/perf_shared.js
diff --git a/chrome/test/data/indexeddb/perf_shared.js b/chrome/test/data/indexeddb/perf_shared.js
index 9e8b3201801bacafe11219e34fe779034289288f..69f74b1e5256b668bb3322855bfd2c08ec9961d9 100644
--- a/chrome/test/data/indexeddb/perf_shared.js
+++ b/chrome/test/data/indexeddb/perf_shared.js
@@ -40,7 +40,11 @@ function assert(t) {
}
function onError(e) {
- console.log(e);
+ var s = "Caught error.";
+ if (e.target && e.target.webkitErrorMessage)
+ s += "\n" + e.target.webkitErrorMessage;
+ console.log(s);
+ automation.setStatus(s);
e.stopPropagation();
throw new Error(e);
}
@@ -48,14 +52,26 @@ function onError(e) {
var version = 2; // The version with our object stores.
var db;
jsbell 2012/07/26 18:23:30 db is global here, but passed as arguments elsewhe
ericu 2012/07/26 20:24:11 Done.
-function createDatabase(name, objectStores, handler, errorHandler) {
+// Valid options fields:
+// indexName: the name of an index to create on each object store
+// indexKeyPath: likewise
+// indexIsUnique: the "unique" option for IDBIndexParameters
+// indexIsMultiEntry: the "multiEntry" option for IDBIndexParameters
+//
+function createDatabase(name, objectStores, handler, errorHandler, options) {
jsbell 2012/07/26 18:23:30 So, rather than special casing options for indexes
ericu 2012/07/26 20:24:11 Let me think about that one for a later CL. Depen
var openRequest = indexedDB.open(name, version);
openRequest.onblocked = errorHandler;
function createObjectStores(db) {
for (var store in objectStores) {
var name = objectStores[store];
assert(!db.objectStoreNames.contains(name));
- db.createObjectStore(name);
+ var os = db.createObjectStore(name);
+ if (options && options.indexName) {
+ assert(options.indexKeyPath || options.indexKeyPath == "");
jsbell 2012/07/26 18:23:30 I'd go with: assert('indexKeyPath' in options);
ericu 2012/07/26 20:24:11 Much better, thanks.
+ os.createIndex(options.indexName, options.indexKeyPath,
+ { unique: options.indexIsUnique,
+ multiEntry: options.indexIsMultiEntry });
+ }
}
}
openRequest.onupgradeneeded = function(ev) {
@@ -109,10 +125,19 @@ function deleteDatabase(name, opt_handler) {
}
}
-function cleanUp(opt_handler) {
- if (db) {
- deleteDatabase(db, opt_handler);
- db = null;
+function getCleanUpFunc(testName, startTime, onTestComplete) {
+ function onDeleted() {
+ automation.setStatus("Deleted database.");
+ onTestComplete();
+ }
+ return function() {
+ var duration = Date.now() - startTime;
+ // Ignore the cleanup time for this test.
+ automation.addResult(testName, duration);
+ automation.setStatus("Deleting database.");
+ // TODO: Turn on actual deletion; for now it's way too slow.
+ // deleteDatabase(testName, onDeleted);
+ onTestComplete();
}
}
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | chrome/test/data/indexeddb/perf_test.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698