blob: d06f37587765aae4da681c8857ab8db1890dae19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { CookieXPCShellUtils } = ChromeUtils.importESModule(
"resource://testing-common/CookieXPCShellUtils.sys.mjs"
);
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 uri = NetUtil.newURI("http://example.org/");
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);
await CookieXPCShellUtils.setCookieToDocument("http://example.net/", set);
actual = await CookieXPCShellUtils.getCookieStringFromDocument(
"http://example.net/"
);
expected = "foo=bar";
Assert.equal(actual, expected);
Services.prefs.clearUserPref("dom.security.https_first");
});
|