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(); |
} |
} |