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="/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";
|
|
|
|
const objectStoreName = "Objects";
|
|
|
|
|
|
|
|
let testString = { key: 0, value: "testString" };
|
|
|
|
let testInt = { key: 1, value: 1002 };
|
|
|
|
|
2011-10-20 09:10:56 -07:00
|
|
|
let request = mozIndexedDB.open(name, 1, description);
|
2010-06-23 12:46:08 -07:00
|
|
|
request.onerror = errorHandler;
|
2011-10-20 09:10:56 -07:00
|
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
2010-06-23 12:46:08 -07:00
|
|
|
let event = yield;
|
|
|
|
|
2011-01-06 22:21:36 -08:00
|
|
|
let db = event.target.result;
|
2010-10-19 10:58:52 -07:00
|
|
|
|
2010-12-21 08:02:01 -08:00
|
|
|
let objectStore = db.createObjectStore(objectStoreName,
|
|
|
|
{ autoIncrement: 0 });
|
2010-06-23 12:46:08 -07:00
|
|
|
|
|
|
|
request = objectStore.add(testString.value, testString.key);
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.result, testString.key, "Got the right key");
|
2010-06-23 12:46:08 -07:00
|
|
|
request = objectStore.get(testString.key);
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.result, testString.value, "Got the right value");
|
2010-06-23 12:46:08 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
request = objectStore.add(testInt.value, testInt.key);
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.result, testInt.key, "Got the right key");
|
2010-06-23 12:46:08 -07:00
|
|
|
request = objectStore.get(testInt.key);
|
|
|
|
request.onerror = errorHandler;
|
|
|
|
request.onsuccess = function(event) {
|
2011-01-06 22:21:36 -08:00
|
|
|
is(event.target.result, testInt.value, "Got the right value");
|
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>
|