gecko/dom/indexedDB/test/leaving_page_iframe.html

46 lines
1.1 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<script>
var db;
function startDBWork() {
mozIndexedDB.open(parent.location).onsuccess = function(e) {
db = e.target.result;
db.setVersion("1.0").onsuccess = function(e) {
var trans = e.target.transaction;
if (db.objectStoreNames.contains("mystore")) {
db.deleteObjectStore("mystore");
}
var store = db.createObjectStore("mystore");
store.add({ hello: "world" }, 42);
trans.oncomplete = madeMod;
};
};
}
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>