2010-09-10 02:15:44 +04: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">
|
|
|
|
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
|
|
|
|
|
|
|
let db;
|
|
|
|
|
|
|
|
function onAddMore() {
|
|
|
|
let transaction = db.transaction("foo", READ_WRITE);
|
|
|
|
|
|
|
|
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);
|
2010-10-19 23:14:30 +04:00
|
|
|
|
|
|
|
let request = db.setVersion("2");
|
2010-09-10 02:15:44 +04:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2010-11-11 02:25:57 +03:00
|
|
|
db.deleteObjectStore("foo");
|
2011-01-28 00:47:36 +03:00
|
|
|
request.transaction.oncomplete = function(event) {
|
|
|
|
testResult = "finished";
|
|
|
|
testException = undefined;
|
|
|
|
finishTest();
|
|
|
|
}
|
2010-09-10 02:15:44 +04: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);
|
|
|
|
|
2011-01-03 23:03:06 +03:00
|
|
|
let request = mozIndexedDB.open(name, description);
|
2010-09-10 02:15:44 +04:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
let event = yield;
|
|
|
|
|
2011-01-07 09:21:36 +03:00
|
|
|
db = event.target.result;
|
2010-09-10 02:15:44 +04:00
|
|
|
|
2010-10-19 23:14:30 +04:00
|
|
|
request = db.setVersion("1");
|
2010-09-10 02:15:44 +04:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
event = yield;
|
|
|
|
|
2010-12-21 19:02:01 +03:00
|
|
|
db.createObjectStore("foo", { autoIncrement: true });
|
2010-10-19 23:14:30 +04:00
|
|
|
|
2010-09-10 02:15:44 +04: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>
|