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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* import-globals-from partitionedstorage_head.js */
PartitionedStorageHelper.runTest(
"ServiceWorkers",
async (win3rdParty, win1stParty, allowed) => {
// ServiceWorkers are not supported. Always blocked.
await win3rdParty.navigator.serviceWorker.register("empty.js").then(
_ => {
ok(allowed, "Success: ServiceWorker cannot be used!");
},
_ => {
ok(!allowed, "Failed: ServiceWorker cannot be used!");
}
);
await win1stParty.navigator.serviceWorker.register("empty.js").then(
_ => {
ok(true, "Success: ServiceWorker should be available!");
},
_ => {
ok(false, "Failed: ServiceWorker should be available!");
}
);
},
async _ => {
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
resolve()
);
});
},
[
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.ipc.processCount", 1],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
]
);
PartitionedStorageHelper.runTest(
"ServiceWorkers - MatchAll",
async (win3rdParty, win1stParty, allowed) => {
if (!win1stParty.sw) {
let reg = await win1stParty.navigator.serviceWorker.register(
"matchAll.js"
);
if (reg.installing.state !== "activated") {
await new Promise(resolve => {
let w = reg.installing;
w.addEventListener("statechange", function onStateChange() {
if (w.state === "activated") {
w.removeEventListener("statechange", onStateChange);
win1stParty.sw = reg.active;
resolve();
}
});
});
}
}
let msgPromise = new Promise(resolve => {
win1stParty.navigator.serviceWorker.addEventListener("message", msg => {
resolve(msg.data);
});
});
win1stParty.sw.postMessage(win3rdParty.location.href);
let msg = await msgPromise;
is(allowed, msg, "We want to have the 3rd party window controlled.");
},
async _ => {
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
resolve()
);
});
},
[
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.ipc.processCount", 1],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
]
);
|