browser_storage_fission_cookies.js (2051B)
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/. */ 4 5 "use strict"; 6 7 add_task(async function () { 8 await SpecialPowers.pushPrefEnv({ 9 // Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default" 10 set: [["network.cookie.sameSite.laxByDefault", false]], 11 }); 12 13 const URL_IFRAME = buildURLWithContent( 14 "example.net", 15 `<h1>iframe</h1>` + 16 `<script>document.cookie = "lorem=ipsum; Secure; Partitioned";</script>` 17 ); 18 19 const URL_MAIN = buildURLWithContent( 20 "example.com", 21 `<h1>Main</h1>` + 22 `<script>document.cookie="foo=bar";</script>` + 23 `<iframe src="${URL_IFRAME}">` 24 ); 25 26 // open tab 27 await openTabAndSetupStorage(URL_MAIN); 28 const doc = gPanelWindow.document; 29 30 // check that both hosts appear in the storage tree 31 checkTree(doc, ["cookies", "https://example.com"]); 32 checkTree(doc, ["cookies", "https://example.net"]); 33 // check the table for values 34 await selectTreeItem(["cookies", "https://example.com"]); 35 checkCookieData("foo", "bar"); 36 await selectTreeItem(["cookies", "https://example.net"]); 37 checkCookieData("lorem", "ipsum"); 38 39 info("Add more cookies"); 40 const onUpdated = gUI.once("store-objects-edit"); 41 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 42 content.window.document.cookie = "foo2=bar2"; 43 44 const iframe = content.document.querySelector("iframe"); 45 return SpecialPowers.spawn(iframe, [], () => { 46 content.document.cookie = "lorem2=ipsum2; Secure; Partitioned"; 47 }); 48 }); 49 await onUpdated; 50 51 // check that the new data is shown in the table for the iframe document 52 checkCookieData("lorem2", "ipsum2"); 53 54 // check that the new data is shown in the table for the top-level document 55 await selectTreeItem(["cookies", "https://example.com"]); 56 checkCookieData("foo2", "bar2"); 57 58 SpecialPowers.clearUserPref("network.cookie.sameSite.laxByDefault"); 59 });