dom/indexedDB/test/leaving_page_iframe.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a4d103fca4eb
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 var db;
6 function startDBWork() {
7 indexedDB.open(parent.location, 1).onupgradeneeded = function(e) {
8 db = e.target.result;
9 var trans = e.target.transaction;
10 if (db.objectStoreNames.contains("mystore")) {
11 db.deleteObjectStore("mystore");
12 }
13 var store = db.createObjectStore("mystore");
14 store.add({ hello: "world" }, 42);
15 e.target.onsuccess = madeMod;
16 };
17 }
18
19 function madeMod() {
20 var trans = db.transaction(["mystore"], "readwrite");
21 var store = trans.
22 objectStore("mystore");
23 trans.oncomplete = function() {
24 parent.postMessage("didcommit", "*");
25 }
26
27 store.put({ hello: "officer" }, 42).onsuccess = function(e) {
28 // Make this transaction run until the end of time or until the page is
29 // navigated away, whichever comes first.
30 function doGet() {
31 store.get(42).onsuccess = doGet;
32 }
33 doGet();
34 document.location = "about:blank";
35 }
36
37 }
38 </script>
39 </head>
40 <body onload="startDBWork();">
41 This is page one.
42 </body>
43 </html>

mercurial