2011-01-27 13:47:36 -08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script>
|
|
|
|
var db;
|
|
|
|
function startDBWork() {
|
2011-10-20 09:10:56 -07:00
|
|
|
mozIndexedDB.open(parent.location, 1).onupgradeneeded = function(e) {
|
2011-01-27 13:47:36 -08:00
|
|
|
db = e.target.result;
|
2011-10-20 09:10:56 -07:00
|
|
|
var trans = e.target.transaction;
|
|
|
|
if (db.objectStoreNames.contains("mystore")) {
|
|
|
|
db.deleteObjectStore("mystore");
|
|
|
|
}
|
|
|
|
var store = db.createObjectStore("mystore");
|
|
|
|
store.add({ hello: "world" }, 42);
|
2011-10-25 05:49:31 -07:00
|
|
|
e.target.onsuccess = madeMod;
|
2011-01-27 13:47:36 -08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function madeMod() {
|
|
|
|
var trans = db.transaction(["mystore"], IDBTransaction.READ_WRITE);
|
|
|
|
var store = trans.
|
|
|
|
objectStore("mystore");
|
|
|
|
trans.oncomplete = function() {
|
|
|
|
parent.postMessage("didcommit", "*");
|
|
|
|
}
|
|
|
|
|
|
|
|
store.put({ hello: "officer" }, 42).onsuccess = function(e) {
|
|
|
|
// Make this transaction run until the end of time or until the page is
|
|
|
|
// navigated away, whichever comes first.
|
|
|
|
function doGet() {
|
|
|
|
store.get(42).onsuccess = doGet;
|
|
|
|
}
|
|
|
|
doGet();
|
|
|
|
document.location = "about:blank";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="startDBWork();">
|
|
|
|
This is page one.
|
|
|
|
</body>
|
|
|
|
</html>
|