diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/tests/mochitest/localstorage/test_cookieBlock.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/localstorage/test_cookieBlock.html')
-rw-r--r-- | dom/tests/mochitest/localstorage/test_cookieBlock.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/dom/tests/mochitest/localstorage/test_cookieBlock.html b/dom/tests/mochitest/localstorage/test_cookieBlock.html new file mode 100644 index 0000000000..9cc7495d40 --- /dev/null +++ b/dom/tests/mochitest/localstorage/test_cookieBlock.html @@ -0,0 +1,53 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>cookie blocking test</title> + +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + +<script type="text/javascript"> + +function startTest() +{ + // Let's use a new window to have the cookie permission applied. + let w = window.open("windowProxy.html"); + w.onload = _ => { + try { + w.localStorage.setItem("blocked", "blockedvalue"); + ok(false, "Exception for localStorage.setItem, ACCESS_DENY"); + } + catch (ex) { + ok(true, "Exception for localStorage.setItem, ACCESS_DENY"); + } + + try { + w.localStorage.getItem("blocked"); + ok(false, "Exception for localStorage.getItem, ACCESS_DENY"); + } + catch (ex) { + ok(true, "Exception for localStorage.getItem, ACCESS_DENY"); + } + + w.close(); + SpecialPowers.popPermissions(() => { + SimpleTest.finish(); + }); + } +} + +SimpleTest.waitForExplicitFinish(); + +// Initialize storage before setting the cookie, otherwise we won't be testing +// the checks in setItem/getItem methods. +var storage = localStorage; + +SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': false, 'context': document}], startTest); + +</script> + +</head> + +<body> + +</body> +</html> |