2010-10-19 10:58:52 -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 name = window.location.pathname;
|
|
|
|
const description = "My Test Database";
|
|
|
|
|
2011-01-03 12:03:06 -08:00
|
|
|
let request = mozIndexedDB.open(name, description);
|
2010-10-19 10:58:52 -07:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
let event = yield;
|
|
|
|
|
|
|
|
let versionChangeEventCount = 0;
|
|
|
|
let db1, db2, db3;
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
db1 = event.target.result;
|
2010-10-19 10:58:52 -07:00
|
|
|
db1.addEventListener("versionchange", function(event) {
|
|
|
|
ok(true, "Got version change event");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.source, null, "Correct source");
|
2010-10-19 10:58:52 -07:00
|
|
|
is(event.target, db1, "Correct target");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.version, "", "Correct db version");
|
|
|
|
is(event.version, "1", "Correct event version");
|
2010-10-19 10:58:52 -07:00
|
|
|
is(versionChangeEventCount++, 0, "Correct count");
|
|
|
|
db1.close();
|
|
|
|
}, false);
|
|
|
|
|
2011-01-03 12:03:06 -08:00
|
|
|
request = mozIndexedDB.open(name, description);
|
2010-10-19 10:58:52 -07:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
event = yield;
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
db2 = event.target.result;
|
2010-10-19 10:58:52 -07:00
|
|
|
db2.addEventListener("versionchange", function(event) {
|
|
|
|
ok(true, "Got version change event");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.source, null, "Correct source");
|
2010-10-19 10:58:52 -07:00
|
|
|
is(event.target, db2, "Correct target");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.version, "1", "Correct db version");
|
|
|
|
is(event.version, "2", "Correct event version");
|
2010-10-19 10:58:52 -07:00
|
|
|
is(versionChangeEventCount++, 1, "Correct count");
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
request = db2.setVersion("1");
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
2011-01-06 22:21:36 -08:00
|
|
|
request.onblocked = errorHandler;
|
2010-10-19 10:58:52 -07:00
|
|
|
event = yield;
|
2011-01-06 22:21:36 -08:00
|
|
|
|
|
|
|
ok(event.target.result === event.target.transaction, "Good result");
|
|
|
|
is(event.target.transaction.mode, IDBTransaction.VERSION_CHANGE,
|
|
|
|
"Correct mode");
|
|
|
|
is(db2.version, "1", "Correct db version");
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2011-01-03 12:03:06 -08:00
|
|
|
request = mozIndexedDB.open(name, description);
|
2010-10-19 10:58:52 -07:00
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
event = yield;
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
db3 = event.target.result;
|
2010-10-19 10:58:52 -07:00
|
|
|
|
|
|
|
request = db3.setVersion("2");
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
|
|
request.onblocked = function(event) {
|
|
|
|
ok(true, "Got version change blocked event");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.source, db3, "Correct source");
|
2010-10-19 10:58:52 -07:00
|
|
|
is(event.target, request, "Correct target");
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.source.version, "1", "Correct db version");
|
|
|
|
is(event.version, "2", "Correct event version");
|
2010-10-19 10:58:52 -07:00
|
|
|
versionChangeEventCount++;
|
|
|
|
db2.close();
|
|
|
|
};
|
|
|
|
event = yield;
|
2011-01-06 22:21:36 -08:00
|
|
|
|
|
|
|
ok(event.target.result === event.target.transaction, "Good result");
|
|
|
|
is(event.target.transaction.mode, IDBTransaction.VERSION_CHANGE,
|
|
|
|
"Correct mode");
|
|
|
|
is(db3.version, "2", "Correct db version");
|
2010-10-19 10:58:52 -07:00
|
|
|
|
|
|
|
is(versionChangeEventCount, 3, "Saw all expected events");
|
|
|
|
|
|
|
|
finishTest();
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="runTest();"></body>
|
|
|
|
|
|
|
|
</html>
|