summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js')
-rw-r--r--toolkit/components/antitracking/test/browser/browser_partitionedDedicatedWorker.js58
1 files changed, 58 insertions, 0 deletions
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()
+ );
+ });
+ },
+ []
+);