diff options
Diffstat (limited to 'netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js')
-rw-r--r-- | netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js b/netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js new file mode 100644 index 0000000000..dc1e8eb05f --- /dev/null +++ b/netwerk/test/mochitests/file_documentcookie_maxage_chromescript.js @@ -0,0 +1,45 @@ +/* eslint-env mozilla/chrome-script */ + +"use strict"; + +function getCookieService() { + // eslint-disable-next-line mozilla/use-services + return Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); +} + +function getCookies(cs) { + let cookies = []; + for (let cookie of cs.cookies) { + cookies.push({ + host: cookie.host, + path: cookie.path, + name: cookie.name, + value: cookie.value, + expires: cookie.expires, + }); + } + return cookies; +} + +function removeAllCookies(cs) { + cs.removeAll(); +} + +addMessageListener("init", _ => { + let cs = getCookieService(); + removeAllCookies(cs); + sendAsyncMessage("init:return"); +}); + +addMessageListener("getCookies", _ => { + let cs = getCookieService(); + let cookies = getCookies(cs); + removeAllCookies(cs); + sendAsyncMessage("getCookies:return", { cookies }); +}); + +addMessageListener("shutdown", _ => { + let cs = getCookieService(); + removeAllCookies(cs); + sendAsyncMessage("shutdown:return"); +}); |