<html> <head> <script src="resources/clearLocalStorage.js"></script> <script> if (window.layoutTestController) { layoutTestController.dumpAsText(); layoutTestController.waitUntilDone(); } function log(a) { document.getElementById("logger").innerHTML += a + "<br>"; } function finish() { if (window.layoutTestController) layoutTestController.notifyDone() } function runTest() { if (!window.localStorage) { log("window.localStorage DOES NOT exist"); finish(); return; } log("Setting FOO using the index setter."); localStorage["FOO"] = "BAR"; log("Reading FOO:"); log(localStorage.FOO); log(localStorage["FOO"]); log(localStorage.getItem("FOO")); log(""); log("Setting FOO again, using setItem."); localStorage.setItem("FOO", "BAZ"); log("Reading FOO:"); log(localStorage.FOO); log(localStorage["FOO"]); log(localStorage.getItem("FOO")); log(""); log("Setting FOO again, using the index setter."); localStorage["FOO"] = "BAT"; log("Reading FOO:"); log(localStorage.FOO); log(localStorage["FOO"]); log(localStorage.getItem("FOO")); log(""); log("Setting FOO again, using property-slot syntax"); localStorage.FOO = "BATMAN"; log("Reading FOO:"); log(localStorage.FOO); log(localStorage["FOO"]); log(localStorage.getItem("FOO")); log(""); log("Removing FOO, then trying to read it"); localStorage.removeItem("FOO"); log("Reading FOO:"); log(localStorage.FOO); log(localStorage["FOO"]); log(localStorage.getItem("FOO")); log(""); finish(); } </script> </head> <body onload="runTest();"> This is a test to make sure you can get and set values in localStorage by index.<br> <div id="logger"></div> </body> </html>