From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../browser/browser_partitionedDedicatedWorker.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js (limited to 'toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js') diff --git a/toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js b/toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js new file mode 100644 index 0000000000..55156beca3 --- /dev/null +++ b/toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js @@ -0,0 +1,58 @@ +PartitionedStorageHelper.runTestInNormalAndPrivateMode( + "DedicatedWorkers", + async (win3rdParty, win1stParty) => { + // Set one cookie to the first party context. + await win1stParty.fetch("cookies.sjs?first").then(r => r.text()); + + // Create a dedicated worker in the first-party context. + let firstPartyWorker = new win1stParty.Worker("dedicatedWorker.js"); + + // Verify that the cookie from the first-party worker. + await new Promise(resolve => { + firstPartyWorker.addEventListener("message", msg => { + is( + msg.data, + "cookie:foopy=first", + "Got the expected first-party cookie." + ); + resolve(); + }); + + firstPartyWorker.postMessage("getCookies"); + }); + + // Set one cookie to the third-party context. + await win3rdParty + .fetch("cookies.sjs?3rd;Partitioned;Secure") + .then(r => r.text()); + + // Create a dedicated worker in the third-party context. + let thirdPartyWorker = new win3rdParty.Worker("dedicatedWorker.js"); + + // Verify that the third-party worker cannot access first-party cookies. + await new Promise(resolve => { + thirdPartyWorker.addEventListener("message", msg => { + is( + msg.data, + "cookie:foopy=3rd", + "Got the expected third-party cookie." + ); + resolve(); + }); + + thirdPartyWorker.postMessage("getCookies"); + }); + + firstPartyWorker.terminate(); + thirdPartyWorker.terminate(); + }, + + async _ => { + await new Promise(resolve => { + Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () => + resolve() + ); + }); + }, + [] +); -- cgit v1.2.3