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