dom/indexedDB/test/leaving_page_iframe.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/leaving_page_iframe.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <script>
     1.8 +var db;
     1.9 +function startDBWork() {
    1.10 +  indexedDB.open(parent.location, 1).onupgradeneeded = function(e) {
    1.11 +    db = e.target.result;
    1.12 +    var trans = e.target.transaction;
    1.13 +    if (db.objectStoreNames.contains("mystore")) {
    1.14 +      db.deleteObjectStore("mystore");
    1.15 +    }
    1.16 +    var store = db.createObjectStore("mystore");
    1.17 +    store.add({ hello: "world" }, 42);
    1.18 +    e.target.onsuccess = madeMod;
    1.19 +  };
    1.20 +}
    1.21 +
    1.22 +function madeMod() {
    1.23 +  var trans = db.transaction(["mystore"], "readwrite");
    1.24 +  var store = trans.
    1.25 +              objectStore("mystore");
    1.26 +  trans.oncomplete = function() {
    1.27 +    parent.postMessage("didcommit", "*");
    1.28 +  }
    1.29 +
    1.30 +  store.put({ hello: "officer" }, 42).onsuccess = function(e) {
    1.31 +    // Make this transaction run until the end of time or until the page is
    1.32 +    // navigated away, whichever comes first.
    1.33 +    function doGet() {
    1.34 +      store.get(42).onsuccess = doGet;
    1.35 +    }
    1.36 +    doGet();
    1.37 +    document.location = "about:blank";
    1.38 +  }
    1.39 +  
    1.40 +}
    1.41 +  </script>
    1.42 +</head>
    1.43 +<body onload="startDBWork();">
    1.44 +  This is page one.
    1.45 +</body>
    1.46 +</html>

mercurial