blob: 55156beca3faf0ec9732d8df4c3b1ed0fcaa1eb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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()
);
});
},
[]
);
|