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>
5 <p>Please follow these steps in order:
</p>
7 <p>First, click
<a href=
"javascript: setData()">here
</a> to open a database and set some data within it.
</p>
9 <p>Next, close the browser and then re-open this page.
</p>
11 <p>Lastly, click
<a href=
"javascript: verifyData()">here
</a> to verify the data was there
</p>
13 <p>Status:
<span id=status
>...
</span></p>
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>";
20 document
.getElementById("enabled").innerHTML
= "<font color=green>Your build seems to have it enabled.</font>";
22 function status(str
, color
)
25 str
= "<font color='" + color
+ "'>" + str
+ "</font>";
26 document
.getElementById("status").innerHTML
= str
;
31 status("Something must have gone wrong (or we're still working)...", "red");
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");
47 status("Something must have gone wrong (or we're still working)...", "red");
49 indexedDB
.open("someDB", "some description").onsuccess = function() {
51 var result
= event
.result
.transaction([]).objectStore("test").get("key");
52 result
.onsuccess = function() {
53 if (event
.result
== "value")
54 status("Value verified", "green");
56 status("Value incorrect!", "red");
58 result
.onerror = function() {
59 status("An error occurred: " + event
.code
+ " " + event
.message
, "red");
62 status("An exception occurred: " + e
, "red");