dom/indexedDB/test/leaving_page_iframe.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     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 }
    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   }
    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   }
    37 }
    38   </script>
    39 </head>
    40 <body onload="startDBWork();">
    41   This is page one.
    42 </body>
    43 </html>

mercurial