<html>
<head>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function log(a)
{
document.getElementById("logger").innerHTML += a + "<br>";
}
function openIframe()
{
if (document.createElement && (iframe = document.createElement('iframe'))) {
document.body.appendChild(iframe);
return iframe;
}
}
function runTest()
{
if (!window.localStorage) {
log("window.localStorage DOES NOT exist");
return;
}
localStorage.clear();
if (window.testRunner && testRunner.setStorageAllowed)
testRunner.setStorageAllowed(true);
else
log("This test requires testRunner.setStorageAllowed, so it be can't run in a browser.");
log("Length is " + localStorage.length);
log("Value for FOO is " + localStorage.getItem("FOO"));
localStorage.setItem("FOO", "BAR");
log("Length is " + localStorage.length);
log("Value for FOO is " + localStorage.getItem("FOO"));
log("Key for index 0 is " + localStorage.key(0));
log("Disabling localStorage access.");
if (window.testRunner && testRunner.setStorageAllowed)
testRunner.setStorageAllowed(false);
try {
log("frame localStorage is accessible " + !!openIframe().contentDocument.defaultView.localStorage);
} catch(e) {
log("Caught exception trying to get frame localStorage: " + e);
}
}
</script>
</head>
<body onload="runTest();">
This test verifies that all access to localStorage can be blocked<br>
<div id="logger"></div>
</body>
</html>