| <html> |
| <head> |
| <script> |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| function log(a) |
| { |
| document.getElementById("logger").innerHTML += a + "<br>"; |
| } |
| |
| function runTest() |
| { |
| if (!window.localStorage) { |
| log("window.localStorage DOES NOT exist"); |
| return; |
| } |
| localStorage.clear(); |
| |
| log("Length is " + localStorage.length); |
| log("Value for FOO is " + localStorage.getItem("FOO")); |
| |
| localStorage.setItem("FOO", "BAR"); |
| |
| log("Length is " + localStorage.length); |
| log("Value for FOO is " + localStorage.getItem("FOO")); |
| log("Key for index 0 is " + localStorage.key(0)); |
| log("Key for index 1 is " + localStorage.key(1)); |
| log("Key for index -1 is " + localStorage.key(-1)); |
| |
| localStorage.setItem("FOO", "BAZ"); |
| |
| log("Length is " + localStorage.length); |
| log("Value for FOO is " + localStorage.getItem("FOO")); |
| |
| localStorage.removeItem("FOO"); |
| |
| log("Length is " + localStorage.length); |
| log("Value for FOO is " + localStorage.getItem("FOO")); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest();"> |
| This test tries simple operations on localStorage<br> |
| <div id="logger"></div> |
| </body> |
| </html> |