1 <html> 2 <head> 3 <script> 4 5 if (window.layoutTestController) 6 layoutTestController.dumpAsText(); 7 8 function log(a) 9 { 10 document.getElementById("logger").innerHTML += a + "<br>"; 11 } 12 13 function testStorage(name, storage) 14 { 15 if ("length" in storage) 16 log("Storage object " + name + " has length"); 17 if ("key" in storage) 18 log("Storage object " + name + " has key"); 19 if ("getItem" in storage) 20 log("Storage object " + name + " has getItem"); 21 if ("setItem" in storage) 22 log("Storage object " + name + " has setItem"); 23 if ("removeItem" in storage) 24 log("Storage object " + name + " has removeItem"); 25 if ("clear" in storage) 26 log("Storage object " + name + " has clear"); 27 } 28 29 function runTest() 30 { 31 if ("sessionStorage" in window) { 32 log("window.sessionStorage exists"); 33 testStorage("sessionStorage", window.sessionStorage); 34 log("window.sessionStorage == window.sessionStorage: " + (window.sessionStorage == window.sessionStorage)); 35 log("window.sessionStorage === window.sessionStorage: " + (window.sessionStorage === window.sessionStorage)); 36 } else 37 log("window.sessionStorage DOES NOT exist"); 38 39 if ("localStorage" in window) { 40 log("window.localStorage exists"); 41 testStorage("localStorage", window.localStorage); 42 log("window.localStorage == window.localStorage: " + (window.localStorage == window.localStorage)); 43 log("window.localStorage === window.localStorage: " + (window.localStorage === window.localStorage)); 44 } else 45 log("window.localStorage DOES NOT exist"); 46 47 if ("onstorage" in window) 48 log("window.onstorage exists"); 49 else 50 log("window.onstorage DOES NOT exist"); 51 } 52 53 </script> 54 </head> 55 <body onload="runTest();"> 56 This test checks to see if window.localStorage, window.sessionStorage and window.onstorage exist.<br> 57 <div id="logger"></div> 58 </body> 59 </html> 60