dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:9e8512a5e987
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <title>localStorage cookies settings test</title>
4
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
7
8 <script type="text/javascript">
9
10 SimpleTest.waitForExplicitFinish();
11
12 // Set cookies behavior to "always reject".
13 SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]},
14 test1);
15
16 function test1() {
17 try {
18 localStorage.setItem("contentkey", "test-value");
19 ok(false, "Setting localStorageItem should throw a security exception");
20 }
21 catch(ex) {
22 is(ex.name, "SecurityError");
23 }
24
25 // Set cookies behavior to "ask every time".
26 SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy", 1]],
27 "clear": [["network.cookie.cookieBehavior"]]},
28 test2);
29 }
30
31 function test2() {
32 try {
33 localStorage.setItem("contentkey", "test-value");
34 ok(false, "Setting localStorageItem should throw a security exception");
35 }
36 catch(ex) {
37 is(ex.name, "SecurityError");
38 }
39
40 SimpleTest.finish();
41 }
42
43 </script>
44 </head>
45 <body>
46 </body>
47 </html>

mercurial