2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
8 add_task(async function () {
9 info("Make sure cookie changes in one process are visible in the other");
11 const kRoot = getRootDirectory(gTestPath).replace(
12 "chrome://mochitests/content/",
13 "https://example.com/"
15 const kTestPage = kRoot + "dummy.html";
17 Services.cookies.removeAll();
19 let tab1 = await BrowserTestUtils.openNewForegroundTab({
22 forceNewProcess: true,
24 let tab2 = await BrowserTestUtils.openNewForegroundTab({
27 forceNewProcess: true,
30 let browser1 = gBrowser.getBrowserForTab(tab1);
31 let browser2 = gBrowser.getBrowserForTab(tab2);
33 let pid1 = browser1.frameLoader.remoteTab.osPid;
34 let pid2 = browser2.frameLoader.remoteTab.osPid;
36 // Note, this might not be true once fission is implemented (Bug 1451850)
37 Assert.notEqual(pid1, pid2, "We should have different processes here.");
39 await SpecialPowers.spawn(browser1, [], async function () {
40 is(content.document.cookie, "", "Expecting no cookies");
43 await SpecialPowers.spawn(browser2, [], async function () {
44 is(content.document.cookie, "", "Expecting no cookies");
47 await SpecialPowers.spawn(browser1, [], async function () {
48 content.document.cookie = "a1=test";
51 await SpecialPowers.spawn(browser2, [], async function () {
52 is(content.document.cookie, "a1=test", "Cookie should be set");
53 content.document.cookie = "a1=other_test";
56 await SpecialPowers.spawn(browser1, [], async function () {
57 is(content.document.cookie, "a1=other_test", "Cookie should be set");
58 content.document.cookie = "a2=again";
61 await SpecialPowers.spawn(browser2, [], async function () {
63 content.document.cookie,
64 "a1=other_test; a2=again",
65 "Cookie should be set"
67 content.document.cookie = "a1=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
68 content.document.cookie = "a2=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
71 await SpecialPowers.spawn(browser1, [], async function () {
72 is(content.document.cookie, "", "Cookies should be cleared");
75 BrowserTestUtils.removeTab(tab1);
76 BrowserTestUtils.removeTab(tab2);
78 ok(true, "Got to the end of the test!");