2010-09-09 15:15:44 -07: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;
|
2011-10-20 09:10:56 -07:00
|
|
|
let version = window.location.href.charAt(window.location.href.length - 1);
|
2010-09-09 15:15:44 -07:00
|
|
|
|
|
|
|
function onAddMore() {
|
2012-03-12 21:44:45 -07:00
|
|
|
let transaction = db.transaction("foo", "readwrite");
|
2010-09-09 15:15:44 -07:00
|
|
|
|
|
|
|
transaction.oncomplete = function(event) {
|
|
|
|
setTimeout(testFinishedCallback, 0, "complete");
|
|
|
|
}
|
|
|
|
transaction.onabort = function(event) {
|
2012-06-25 12:15:17 -07:00
|
|
|
setTimeout(testFinishedCallback, 0, "abort " + event.target.error.name);
|
2010-09-09 15:15:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2010-10-19 12:14:30 -07:00
|
|
|
|
2012-06-29 09:48:35 -07:00
|
|
|
let request = indexedDB.open(window.location.pathname, version++);
|
2010-09-09 15:15:44 -07:00
|
|
|
request.onerror = errorHandler;
|
2011-10-20 09:10:56 -07:00
|
|
|
request.onupgradeneeded = function(event) {
|
2010-11-10 15:25:57 -08:00
|
|
|
db.deleteObjectStore("foo");
|
2011-10-20 09:10:56 -07:00
|
|
|
db.onversionchange = function () { db.close(); };
|
2011-01-27 13:47:36 -08:00
|
|
|
request.transaction.oncomplete = function(event) {
|
|
|
|
testResult = "finished";
|
|
|
|
testException = undefined;
|
|
|
|
finishTest();
|
|
|
|
}
|
2010-09-09 15:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSteps()
|
|
|
|
{
|
|
|
|
const name = window.location.pathname;
|
|
|
|
const description = "My Test Database";
|
|
|
|
|
|
|
|
window.addEventListener("indexedDB-addMore", onAddMore, true);
|
|
|
|
window.addEventListener("indexedDB-done", onDone, true);
|
|
|
|
|
2012-06-29 09:48:35 -07:00
|
|
|
let request = indexedDB.open(name, version++, description);
|
2010-09-09 15:15:44 -07:00
|
|
|
request.onerror = errorHandler;
|
2011-10-20 09:10:56 -07:00
|
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
2010-09-09 15:15:44 -07:00
|
|
|
let event = yield;
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
db = event.target.result;
|
2010-09-09 15:15:44 -07:00
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
db.onversionchange = function () { db.close(); };
|
2010-09-09 15:15:44 -07:00
|
|
|
|
2010-12-21 08:02:01 -08:00
|
|
|
db.createObjectStore("foo", { autoIncrement: true });
|
2010-10-19 12:14:30 -07:00
|
|
|
|
2011-10-25 05:49:31 -07:00
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
yield;
|
|
|
|
|
2010-09-09 15:15:44 -07:00
|
|
|
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>
|