1 <html> 2 <head> 3 <script src="resources/clearSessionStorage.js"></script> 4 <script> 5 6 if (window.layoutTestController) 7 layoutTestController.dumpAsText(); 8 9 function log(a) 10 { 11 document.getElementById("logger").innerHTML += a + "<br>"; 12 } 13 14 function runTest() 15 { 16 if (!window.sessionStorage) { 17 log("window.sessionStorage DOES NOT exist"); 18 return; 19 } 20 21 log("Length is " + window.sessionStorage.length); 22 log("Value for FOO is " + window.sessionStorage.getItem("FOO")); 23 24 window.sessionStorage.setItem("FOO", "BAR"); 25 26 log("Length is " + window.sessionStorage.length); 27 log("Value for FOO is " + window.sessionStorage.getItem("FOO")); 28 log("Key for index 0 is " + window.sessionStorage.key(0)); 29 log("Key for index 1 is " + window.sessionStorage.key(1)); 30 log("Key for index -1 is " + window.sessionStorage.key(-1)); 31 32 window.sessionStorage.setItem("FOO", "BAZ"); 33 34 log("Length is " + window.sessionStorage.length); 35 log("Value for FOO is " + window.sessionStorage.getItem("FOO")); 36 37 window.sessionStorage.removeItem("FOO"); 38 39 log("Length is " + window.sessionStorage.length); 40 log("Value for FOO is " + window.sessionStorage.getItem("FOO")); 41 } 42 43 </script> 44 </head> 45 <body onload="runTest();"> 46 This test trys simple operations on SessionStorage<br> 47 <div id="logger"></div> 48 </body> 49 </html> 50