blob: 8dc65befb82b24c4d6384d9bc3d9bb14d0c17f90 (
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
|
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1208559 - ServiceWorker registration not governed by CSP</title>
</head>
<body>
<script>
function finish(status) {
window.parent.postMessage({result: status}, "*");
}
const BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN = 5;
const cookieBehavior = SpecialPowers.getIntPref("network.cookie.cookieBehavior");
const promises = [
navigator.serviceWorker.ready,
navigator.serviceWorker.register("file_service_worker.js", { scope: "." })
];
if (cookieBehavior == BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) {
Promise.allSettled(promises).then(results => {
const resultValues = results
.map(result =>
result.status === "fulfilled" ? "allowed" : "blocked"
)
.join(",");
finish(resultValues);
});
} else {
Promise.race(promises).then(finish.bind(null, 'allowed'),
finish.bind(null, 'blocked'));
}
</script>
</body>
</html>
|