Home | History | Annotate | Download | only in localstorage
      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     if (!window.layoutTestController) {
     21         log("Test only designed to be run under DumpRenderTree");
     22         return;
     23     }
     24     
     25     localStorage.setItem("testItem", "InitialValue");    
     26     layoutTestController.setPrivateBrowsingEnabled(true);
     27     log("Initial value of testItem is: " + localStorage.getItem("testItem"));
     28 
     29     try {
     30         localStorage.setItem("testItem", "ChangedValue");
     31     } catch(e) {
     32         log("Caught exception trying to change item: " + e);
     33     }
     34 
     35     log("After change attempt, testItem is: " + localStorage.getItem("testItem"));
     36     
     37     localStorage.removeItem("testItem");
     38     log("After remove attempt, testItem is: " + localStorage.getItem("testItem"));
     39 
     40     localStorage.clear();
     41     log("After clear attempt, testItem is: " + localStorage.getItem("testItem"));
     42 }
     43 
     44 </script>
     45 </head>
     46 <body onload="runTest();">
     47 This is a test to make sure that when private browsing is on any attempt to change the localStorage area fail.
     48 <div id="logger"></div>
     49 </body>
     50 </html>
     51