Home | History | Annotate | Download | only in ManualTests
      1 <html>
      2 <body>
      3 <p>This is a test that only applies to IndexedDB.  <span id=enabled>Our test for whether you have it enabled seems to have failed.</span></p>
      4 
      5 <p>Please follow these steps in order:</p>
      6 
      7 <p>First, click <a href="javascript: setData()">here</a> to open a database and set some data within it.</p>
      8 
      9 <p>Next, close the browser and then re-open this page.</p>
     10 
     11 <p>Lastly, click <a href="javascript: verifyData()">here</a> to verify the data was there</p>
     12 
     13 <p>Status: <span id=status>...</span></p>
     14 
     15 <script>
     16 
     17 if (!('indexedDB' in window))
     18     document.getElementById("enabled").innerHTML = "<font color=red>Your build does NOT seem to have it enabled.  So all code on this page is disabled.</font>";
     19 else
     20     document.getElementById("enabled").innerHTML = "<font color=green>Your build seems to have it enabled.</font>";
     21 
     22 function status(str, color)
     23 {
     24     if (color)
     25         str = "<font color='" + color + "'>" + str + "</font>";
     26     document.getElementById("status").innerHTML = str;
     27 }
     28 
     29 function setData()
     30 {
     31     status("Something must have gone wrong (or we're still working)...", "red");
     32 
     33     indexedDB.open("someDB", "some description").onsuccess = function() {
     34         event.result.setVersion("some version").onsuccess = function() {
     35             var db = event.source;
     36             while (db.objectStoreNames.length)
     37                 db.removeObjectStore(db.objectStoreNames[0]);
     38             db.createObjectStore("test").put("value", "key").onsuccess = function() {
     39                 status("Value set", "green");
     40             }
     41         }
     42     }
     43 }
     44 
     45 function verifyData()
     46 {
     47     status("Something must have gone wrong (or we're still working)...", "red");
     48 
     49     indexedDB.open("someDB", "some description").onsuccess = function() {
     50         try {
     51             var result = event.result.transaction([]).objectStore("test").get("key");
     52             result.onsuccess = function() {
     53                 if (event.result == "value")
     54                     status("Value verified", "green");
     55                 else
     56                     status("Value incorrect!", "red");
     57             }
     58             result.onerror = function() {
     59                 status("An error occurred: " + event.code + " " + event.message, "red");
     60             }
     61         } catch (e) {
     62             status("An exception occurred: " + e, "red");
     63         }
     64     }
     65 }
     66 
     67 </script>
     68 </body>
     69 </html>
     70