gecko/dom/tests/mochitest/localstorage/test_cookieBlock.html
Honza Bambas 1027f32e5c Bug 487695 - Decide on localStorage behavior in session-only cookies or private-browsing mode, r+sr=jst
--HG--
rename : dom/src/storage/nsDOMStorageDB.cpp => dom/src/storage/nsDOMStoragePersistentDB.cpp
rename : dom/src/storage/nsDOMStorageDB.h => dom/src/storage/nsDOMStoragePersistentDB.h
2009-05-18 10:12:14 +02:00

54 lines
1.4 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>cookie blocking test</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript">
function startTest()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var io = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_DENY);
try {
localStorage.setItem("blocked", "blockedvalue");
ok(false, "Exception for localStorage.setItem, ACCESS_DENY");
}
catch (ex) {
ok(true, "Exception for localStorage.setItem, ACCESS_DENY");
}
try {
localStorage.getItem("blocked");
ok(false, "Exception for localStorage.getItem, ACCESS_DENY");
}
catch (ex) {
ok(true, "Exception for localStorage.getItem, ACCESS_DENY");
}
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_DEFAULT);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="startTest();">
</body>
</html>