1 <html> 2 <head> 3 <script src="resources/clearSessionStorage.js"></script> 4 <script> 5 6 if (window.layoutTestController) { 7 layoutTestController.dumpAsText(); 8 layoutTestController.waitUntilDone(); 9 } 10 11 function log(a) 12 { 13 document.getElementById("logger").innerHTML += a + "<br>"; 14 } 15 16 function finish() 17 { 18 if (window.layoutTestController) 19 layoutTestController.notifyDone() 20 } 21 22 function runTest() 23 { 24 if (!window.sessionStorage) { 25 log("window.sessionStorage DOES NOT exist"); 26 finish(); 27 return; 28 } 29 30 log("Setting FOO using the index setter."); 31 sessionStorage["FOO"] = "BAR"; 32 log("Reading FOO:"); 33 log(sessionStorage.FOO); 34 log(sessionStorage["FOO"]); 35 log(sessionStorage.getItem("FOO")); 36 log(""); 37 38 log("Setting FOO again, using setItem."); 39 sessionStorage.setItem("FOO", "BAZ"); 40 log("Reading FOO:"); 41 log(sessionStorage.FOO); 42 log(sessionStorage["FOO"]); 43 log(sessionStorage.getItem("FOO")); 44 log(""); 45 46 log("Setting FOO again, using the index setter."); 47 sessionStorage["FOO"] = "BAT"; 48 log("Reading FOO:"); 49 log(sessionStorage.FOO); 50 log(sessionStorage["FOO"]); 51 log(sessionStorage.getItem("FOO")); 52 log(""); 53 54 log("Setting FOO again, using property-slot syntax"); 55 sessionStorage.FOO = "BATMAN"; 56 log("Reading FOO:"); 57 log(sessionStorage.FOO); 58 log(sessionStorage["FOO"]); 59 log(sessionStorage.getItem("FOO")); 60 log(""); 61 62 log("Removing FOO, then trying to read it"); 63 sessionStorage.removeItem("FOO"); 64 log("Reading FOO:"); 65 log(sessionStorage.FOO); 66 log(sessionStorage["FOO"]); 67 log(sessionStorage.getItem("FOO")); 68 log(""); 69 70 finish(); 71 } 72 73 </script> 74 </head> 75 <body onload="runTest();"> 76 This is a test to make sure you can get and set values in SessionStorage by index.<br> 77 <div id="logger"></div> 78 </body> 79 </html> 80