2012-01-04 08:25:26 -08:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Indexed Database Test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript;version=1.7">
|
|
|
|
let db;
|
|
|
|
let name = window.location.pathname;
|
|
|
|
|
|
|
|
function onAddMore() {
|
2012-03-12 21:44:45 -07:00
|
|
|
let transaction = db.transaction("foo", "readwrite");
|
2012-01-04 08:25:26 -08:00
|
|
|
|
|
|
|
transaction.oncomplete = function(event) {
|
|
|
|
setTimeout(testFinishedCallback, 0, "complete");
|
|
|
|
}
|
|
|
|
transaction.onabort = function(event) {
|
|
|
|
setTimeout(testFinishedCallback, 0, "abort");
|
|
|
|
}
|
|
|
|
|
|
|
|
let objectStore = transaction.objectStore("foo");
|
|
|
|
let obj = {
|
|
|
|
foo: " ",
|
|
|
|
bar: " ",
|
|
|
|
baz: " "
|
|
|
|
};
|
|
|
|
for (let i = 0; i < 1000; i++) {
|
|
|
|
objectStore.add(obj).onerror = errorHandler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDone() {
|
|
|
|
window.removeEventListener("indexedDB-addMore", onAddMore, true);
|
|
|
|
window.removeEventListener("indexedDB-done", onDone, true);
|
|
|
|
window.removeEventListener("indexedDB-reset", onReset, true);
|
|
|
|
|
|
|
|
testResult = "finished";
|
|
|
|
testException = undefined;
|
|
|
|
finishTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onReset() {
|
|
|
|
db.close();
|
|
|
|
// N.B. the spec provides no ordering guarantee w.r.t deleteDatabase.
|
2012-06-29 09:48:35 -07:00
|
|
|
let deleteRequest = indexedDB.deleteDatabase(name);
|
2012-01-04 08:25:26 -08:00
|
|
|
|
|
|
|
deleteRequest.onerror = errorHandler;
|
|
|
|
deleteRequest.onsuccess = function () {
|
|
|
|
// It is imperative that we open a different database this time.
|
2012-06-29 09:48:35 -07:00
|
|
|
let request = indexedDB.open("take2", 1);
|
2012-01-04 08:25:26 -08:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onupgradeneeded = function(event) {
|
|
|
|
db = event.target.result;
|
|
|
|
db.createObjectStore("foo", { autoIncrement: true });
|
|
|
|
}
|
|
|
|
request.onsuccess = function ()
|
|
|
|
{ setTimeout(testFinishedCallback, 0, "resetDone"); };
|
|
|
|
request.onblocked = errorHandler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSteps()
|
|
|
|
{
|
|
|
|
window.addEventListener("indexedDB-addMore", onAddMore, true);
|
|
|
|
window.addEventListener("indexedDB-reset", onReset, true);
|
|
|
|
window.addEventListener("indexedDB-done", onDone, true);
|
|
|
|
|
2012-06-29 09:48:35 -07:00
|
|
|
let request = indexedDB.open(name, 1);
|
2012-01-04 08:25:26 -08:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
|
|
|
let event = yield;
|
|
|
|
|
|
|
|
db = event.target.result;
|
|
|
|
|
|
|
|
db.onversionchange = function () { db.close(); };
|
|
|
|
|
|
|
|
db.createObjectStore("foo", { autoIncrement: true });
|
|
|
|
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
yield;
|
|
|
|
|
|
|
|
setTimeout(testFinishedCallback, 0, "ready");
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript;version=1.7" src="browserHelpers.js"></script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="runTest();" onunload="finishTestNow();"></body>
|
|
|
|
|
|
|
|
</html>
|