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 0b1e2615591fda67be02b96b2bf6cbf23ae566c0..062da3eefac3f50eea9e5addc8819377bd786ea8 100644 |
--- a/chrome/test/data/indexeddb/perf_shared.js |
+++ b/chrome/test/data/indexeddb/perf_shared.js |
@@ -278,6 +278,10 @@ function putLinearValues( |
} |
} |
+function verifyResultNonNull(result) { |
+ assert(result != null); |
+} |
+ |
function getRandomValues( |
transaction, objectStoreNames, numReads, numKeys, indexName, getKey) { |
if (!getKey) |
@@ -291,6 +295,7 @@ function getRandomValues( |
var rand = Math.floor(Math.random() * numKeys); |
var request = source.get(getKey(rand)); |
request.onerror = onError; |
+ request.onsuccess = verifyResultNonNull; |
} |
} |
} |
@@ -311,6 +316,20 @@ function putRandomValues( |
} |
} |
+function getSpecificValues(transaction, objectStoreNames, indexName, keys) { |
+ for (var i in objectStoreNames) { |
+ var os = transaction.objectStore(objectStoreNames[i]); |
+ var source = os; |
+ if (indexName) |
+ source = source.index(indexName); |
+ for (var j = 0; j < keys.length; ++j) { |
+ var request = source.get(keys[j]); |
+ request.onerror = onError; |
+ request.onsuccess = verifyResultNonNull; |
+ } |
+ } |
+} |
+ |
// getKey should be deterministic, as we assume that a cursor that starts at |
// getKey(X) and runs through getKey(X + K) has exactly K values available. |
// This is annoying to guarantee generally when using an index, so we avoid both |
@@ -360,3 +379,30 @@ function getValuesFromCursor( |
} |
request.onerror = onError; |
} |
+ |
+function runTransactionBatch(db, count, batchFunc, objectStoreNames, mode, |
+ onComplete) { |
+ var numTransactionsRunning = 0; |
+ |
+ runOneBatch(db); |
+ |
+ function runOneBatch(db) { |
+ if (count <= 0) { |
+ return; |
+ } |
+ --count; |
+ ++numTransactionsRunning; |
+ var transaction = getTransaction(db, objectStoreNames, mode, |
+ function() { |
+ assert(!--numTransactionsRunning); |
+ if (count <= 0) { |
+ onComplete(); |
+ } else { |
+ runOneBatch(db); |
+ } |
+ }); |
+ |
+ batchFunc(transaction); |
+ } |
+} |
+ |