OLD | NEW |
| 1 <!DOCTYPE html> |
1 <html> | 2 <html> |
2 <head> | 3 <head> |
3 <script> | 4 <script> |
4 | 5 |
5 if (window.testRunner) | 6 if (window.testRunner) |
6 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
7 | 8 |
8 function log(a) | 9 function log(a) |
9 { | 10 { |
10 document.getElementById("logger").innerHTML += a + "<br>"; | 11 document.getElementById("logger").innerHTML += a + "<br>"; |
11 } | 12 } |
12 | 13 |
13 function openIframe() | 14 function openIframe() |
14 { | 15 { |
15 if (document.createElement && (iframe = document.createElement('iframe'))) { | 16 if (document.createElement && (iframe = document.createElement('iframe'))) { |
16 document.body.appendChild(iframe); | 17 document.body.appendChild(iframe); |
17 return iframe; | 18 return iframe; |
18 } | 19 } |
19 } | 20 } |
20 | 21 |
21 function runTest() | 22 function runTest() |
22 { | 23 { |
23 if (!window.localStorage) { | 24 if (!window.localStorage) { |
24 log("window.localStorage DOES NOT exist"); | 25 log("window.localStorage DOES NOT exist"); |
25 return; | 26 return; |
26 } | 27 } |
27 | 28 |
28 localStorage.clear(); | 29 localStorage.clear(); |
29 | 30 |
30 if (window.testRunner && testRunner.setStorageAllowed) | 31 if (window.testRunner && testRunner.setStorageAllowed) |
31 testRunner.setStorageAllowed(true); | 32 testRunner.setStorageAllowed(true); |
32 else | 33 else |
33 log("This test requires testRunner.setStorageAllowed, so it be can't run
in a browser."); | 34 log("This test requires testRunner.setStorageAllowed, so it be can't run
in a browser."); |
34 | 35 |
35 log("Length is " + localStorage.length); | 36 log("Length is " + localStorage.length); |
36 log("Value for FOO is " + localStorage.getItem("FOO")); | 37 log("Value for FOO is " + localStorage.getItem("FOO")); |
37 | 38 |
38 localStorage.setItem("FOO", "BAR"); | 39 localStorage.setItem("FOO", "BAR"); |
39 | 40 |
40 log("Length is " + localStorage.length); | 41 log("Length is " + localStorage.length); |
41 log("Value for FOO is " + localStorage.getItem("FOO")); | 42 log("Value for FOO is " + localStorage.getItem("FOO")); |
42 log("Key for index 0 is " + localStorage.key(0)); | 43 log("Key for index 0 is " + localStorage.key(0)); |
43 | 44 |
44 log("Disabling localStorage access."); | 45 log("Disabling localStorage access."); |
45 if (window.testRunner && testRunner.setStorageAllowed) | 46 if (window.testRunner && testRunner.setStorageAllowed) |
46 testRunner.setStorageAllowed(false); | 47 testRunner.setStorageAllowed(false); |
47 | 48 |
48 try { | 49 try { |
49 log("frame localStorage is accessible " + !!openIframe().contentDocument
.defaultView.localStorage); | 50 log("frame localStorage is accessible " + !!openIframe().contentDocument
.defaultView.localStorage); |
50 } catch(e) { | 51 } catch(e) { |
51 log("Caught exception trying to get frame localStorage: " + e); | 52 log("Caught exception trying to get frame localStorage: " + e); |
52 } | 53 } |
53 } | 54 } |
54 | 55 |
55 </script> | 56 </script> |
56 </head> | 57 </head> |
57 <body onload="runTest();"> | 58 <body onload="runTest();"> |
58 This test verifies that all access to localStorage can be blocked<br> | 59 This test verifies that all access to localStorage can be blocked<br> |
59 <div id="logger"></div> | 60 <div id="logger"></div> |
60 </body> | 61 </body> |
61 </html> | 62 </html> |
OLD | NEW |