diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /netwerk/test/unit/test_cookie_blacklist.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_cookie_blacklist.js')
-rw-r--r-- | netwerk/test/unit/test_cookie_blacklist.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_cookie_blacklist.js b/netwerk/test/unit/test_cookie_blacklist.js new file mode 100644 index 0000000000..d6d25927e9 --- /dev/null +++ b/netwerk/test/unit/test_cookie_blacklist.js @@ -0,0 +1,43 @@ +"use strict"; + +const GOOD_COOKIE = "GoodCookie=OMNOMNOM"; +const SPACEY_COOKIE = "Spacey Cookie=Major Tom"; + +add_task(async () => { + Services.prefs.setBoolPref( + "network.cookieJarSettings.unblocked_for_testing", + true + ); + Services.prefs.setBoolPref("dom.security.https_first", false); + + var cookieURI = Services.io.newURI( + "http://mozilla.org/test_cookie_blacklist.js" + ); + const channel = NetUtil.newChannel({ + uri: cookieURI, + loadUsingSystemPrincipal: true, + contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT, + }); + + Services.cookies.setCookieStringFromHttp( + cookieURI, + "BadCookie1=\x01", + channel + ); + Services.cookies.setCookieStringFromHttp(cookieURI, "BadCookie2=\v", channel); + Services.cookies.setCookieStringFromHttp( + cookieURI, + "Bad\x07Name=illegal", + channel + ); + Services.cookies.setCookieStringFromHttp(cookieURI, GOOD_COOKIE, channel); + Services.cookies.setCookieStringFromHttp(cookieURI, SPACEY_COOKIE, channel); + + CookieXPCShellUtils.createServer({ hosts: ["mozilla.org"] }); + + const storedCookie = await CookieXPCShellUtils.getCookieStringFromDocument( + cookieURI.spec + ); + Assert.equal(storedCookie, GOOD_COOKIE + "; " + SPACEY_COOKIE); + Services.prefs.clearUserPref("dom.security.https_first"); +}); |