dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3 <title>localStorage cookies settings test</title>
     5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 <script type="text/javascript">
    10 SimpleTest.waitForExplicitFinish();
    12 // Set cookies behavior to "always reject".
    13 SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]},
    14                           test1);
    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   }
    25   // Set cookies behavior to "ask every time".
    26   SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy", 1]],
    27                              "clear": [["network.cookie.cookieBehavior"]]},
    28                             test2);
    29 }
    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   }
    40   SimpleTest.finish();
    41 }
    43 </script>
    44 </head>
    45 <body>
    46 </body>
    47 </html>

mercurial