2010-06-23 12:46:08 -07:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Indexed Database Property Test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
|
|
|
|
<script type="text/javascript;version=1.7">
|
|
|
|
function testSteps()
|
|
|
|
{
|
|
|
|
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
|
|
|
|
|
|
|
const name = window.location.pathname;
|
|
|
|
const description = "My Test Database";
|
|
|
|
const objectStores = [ "foo", "bar" ];
|
|
|
|
|
|
|
|
let request = moz_indexedDB.open(name, description);
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
let event = yield;
|
|
|
|
|
|
|
|
let db = event.result;
|
|
|
|
is(db.objectStoreNames.length, 0, "Correct objectStoreNames list");
|
|
|
|
|
2010-10-19 10:58:52 -07:00
|
|
|
request = db.setVersion("1");
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
|
|
|
event.transaction.oncomplete = grabEventAndContinueHandler;
|
|
|
|
for (let i in objectStores) {
|
|
|
|
db.createObjectStore(objectStores[i], "", true);
|
|
|
|
}
|
|
|
|
};
|
2010-06-23 12:46:08 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
is(db.objectStoreNames.length, objectStores.length,
|
|
|
|
"Correct objectStoreNames list");
|
|
|
|
|
|
|
|
for (let i = 0; i < 50; i++) {
|
|
|
|
let stepNumber = 0;
|
|
|
|
|
|
|
|
request = db.transaction(["foo"], READ_WRITE)
|
|
|
|
.objectStore("foo")
|
|
|
|
.add({});
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2010-07-12 07:05:01 -07:00
|
|
|
is(stepNumber, 1, "This callback came first");
|
|
|
|
stepNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = db.transaction(["foo"], READ_WRITE)
|
|
|
|
.objectStore("foo")
|
|
|
|
.add({});
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
|
|
|
is(stepNumber, 2, "This callback came second");
|
2010-07-12 07:05:01 -07:00
|
|
|
stepNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = db.transaction(["foo", "bar"], READ_WRITE)
|
|
|
|
.objectStore("bar")
|
|
|
|
.add({});
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2010-07-12 07:05:01 -07:00
|
|
|
is(stepNumber, 3, "This callback came third");
|
|
|
|
stepNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = db.transaction(["foo", "bar"], READ_WRITE)
|
|
|
|
.objectStore("bar")
|
|
|
|
.add({});
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
|
|
|
is(stepNumber, 4, "This callback came fourth");
|
2010-06-23 12:46:08 -07:00
|
|
|
stepNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = db.transaction(["bar"], READ_WRITE)
|
|
|
|
.objectStore("bar")
|
|
|
|
.add({});
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2010-07-12 07:05:01 -07:00
|
|
|
is(stepNumber, 5, "This callback came fifth");
|
2010-06-23 12:46:08 -07:00
|
|
|
stepNumber++;
|
2010-07-12 07:05:01 -07:00
|
|
|
event.transaction.oncomplete = grabEventAndContinueHandler;
|
2010-06-23 12:46:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
stepNumber++;
|
|
|
|
yield;
|
|
|
|
|
2010-07-12 07:05:01 -07:00
|
|
|
is(stepNumber, 6, "All callbacks received");
|
2010-06-23 12:46:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
finishTest();
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="runTest();"></body>
|
|
|
|
|
|
|
|
</html>
|