Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: netwerk/cookie/test/unit/xpcshell.toml
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const { CookieXPCShellUtils } = ChromeUtils.importESModule(
);
CookieXPCShellUtils.init(this);
CookieXPCShellUtils.createServer({ hosts: ["example.net"] });
add_task(async () => {
Services.prefs.setBoolPref("dom.security.https_first", false);
// Allow all cookies.
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieJarSettings.unblocked_for_testing",
true
);
let channel = NetUtil.newChannel({
uri,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
});
let set = "foo=bar\nbaz=foo";
let expected = "foo=bar; baz=foo";
Services.cookies.setCookieStringFromHttp(uri, set, channel);
let actual = Services.cookies.getCookieStringFromHttp(uri, channel);
Assert.equal(actual, expected);
actual = await CookieXPCShellUtils.getCookieStringFromDocument(
);
expected = "";
Assert.equal(actual, expected);
Services.prefs.clearUserPref("dom.security.https_first");
});