1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * Test that channels with different LoadInfo
7 * are stored in separate namespaces ("cookie jars")
13 ChromeUtils.defineLazyGetter(this, "URL", function () {
14 return `http://${ip}:${httpserver.identity.primaryPort}/`;
17 const { HttpServer } = ChromeUtils.importESModule(
18 "resource://testing-common/httpd.sys.mjs"
21 let httpserver = new HttpServer();
23 function cookieSetHandler(metadata, response) {
24 response.setStatusLine(metadata.httpVersion, 200, "Ok");
27 `Set-Cookie: T1=T2; path=/; SameSite=Lax; domain=${ip}; httponly`,
30 response.setHeader("Content-Type", "text/html");
31 response.setHeader("Content-Length", "2");
32 response.bodyOutputStream.write("Ok", "Ok".length);
35 add_task(async function test_cookie_ipv6() {
36 Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
37 Services.prefs.setBoolPref(
38 "network.cookieJarSettings.unblocked_for_testing",
42 httpserver.registerPathHandler("/", cookieSetHandler);
43 httpserver._start(-1, ip);
45 var chan = NetUtil.newChannel({
47 loadUsingSystemPrincipal: true,
49 await new Promise(resolve => {
50 chan.asyncOpen(new ChannelListener(resolve));
52 equal(Services.cookies.cookies.length, 1);