gecko/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html

48 lines
1.1 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>localStorage cookies settings test</title>
<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">
window.Services = SpecialPowers.Services;
// Set cookies behavior to "always reject".
Services.prefs.setIntPref("network.cookie.cookieBehavior", 2);
try {
localStorage.setItem("contentkey", "test-value");
ok(false, "Setting localStorageItem should throw a security exception");
}
catch(ex) {
is(ex.name, "SecurityError");
}
try {
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
}
catch (ex) {}
// Set cookies behavior to "ask every time".
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 1);
try {
localStorage.setItem("contentkey", "test-value");
ok(false, "Setting localStorageItem should throw a security exception");
}
catch(ex) {
is(ex.name, "SecurityError");
}
try {
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
}
catch (ex) {}
</script>
</head>
<body>
</body>
</html>