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