1 <html> 2 <head> 3 <script src="resources/clearLocalStorage.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.localStorage) { 17 log("window.localStorage DOES NOT exist"); 18 return; 19 } 20 21 log("Length is " + localStorage.length); 22 23 log("Testing implicit setters"); 24 localStorage.a = null; 25 log("Type/value for null is " + typeof localStorage.a + "/" + localStorage.a); 26 localStorage.b = 0; 27 log("Type/value for 0 is " + typeof localStorage.b + "/" + localStorage.b); 28 localStorage.c = function(){}; 29 log("Type/value for function(){} is " + typeof localStorage.c + "/" + localStorage.c); 30 31 log("Testing explicit setters"); 32 localStorage.setItem('d', null); 33 log("Type/value for null is " + typeof localStorage.d + "/" + localStorage.d); 34 localStorage.setItem('e', 0); 35 log("Type/value for 0 is " + typeof localStorage.e + "/" + localStorage.e); 36 localStorage.setItem('f', function(){}); 37 log("Type/value for function(){} is " + typeof localStorage.f + "/" + localStorage.f); 38 39 log("Testing index setters"); 40 localStorage['g'] = null; 41 log("Type/value for null is " + typeof localStorage.g + "/" + localStorage.g); 42 localStorage['h'] = 0; 43 log("Type/value for 0 is " + typeof localStorage.h + "/" + localStorage.h); 44 localStorage['i'] = function(){}; 45 log("Type/value for function(){} is " + typeof localStorage.i + "/" + localStorage.i); 46 } 47 48 </script> 49 </head> 50 <body onload="runTest();"> 51 This test case verifies that local storage only stores strings. 52 <div id="logger"></div> 53 </body> 54 </html> 55