dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +<title>localStorage cookies settings test</title>
     1.7 +
     1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +<script type="text/javascript">
    1.12 +
    1.13 +SimpleTest.waitForExplicitFinish();
    1.14 +
    1.15 +// Set cookies behavior to "always reject".
    1.16 +SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]},
    1.17 +                          test1);
    1.18 +
    1.19 +function test1() {
    1.20 +  try {
    1.21 +    localStorage.setItem("contentkey", "test-value");
    1.22 +    ok(false, "Setting localStorageItem should throw a security exception");
    1.23 +  }
    1.24 +  catch(ex) {
    1.25 +    is(ex.name, "SecurityError");
    1.26 +  }
    1.27 +
    1.28 +  // Set cookies behavior to "ask every time".
    1.29 +  SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy", 1]],
    1.30 +                             "clear": [["network.cookie.cookieBehavior"]]},
    1.31 +                            test2);
    1.32 +}
    1.33 +
    1.34 +function test2() {
    1.35 +  try {
    1.36 +    localStorage.setItem("contentkey", "test-value");
    1.37 +    ok(false, "Setting localStorageItem should throw a security exception");
    1.38 +  }
    1.39 +  catch(ex) {
    1.40 +    is(ex.name, "SecurityError");
    1.41 +  }
    1.42 +
    1.43 +  SimpleTest.finish();
    1.44 +}
    1.45 +
    1.46 +</script>
    1.47 +</head>
    1.48 +<body>
    1.49 +</body>
    1.50 +</html>

mercurial