blob: 4d2680538f385d45387e5ec0e8d523bfedec91ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
addEventListener("fetch", event => {
var url = event.request.url;
var badURL = url.indexOf("secret.html") > -1;
event.respondWith(
new Promise(resolve => {
clients.matchAll().then(clients => {
for (var client of clients) {
if (client.url.indexOf("index.html") > -1) {
client.postMessage({
status: "ok",
result: !badURL,
message: "Should not find a bad URL (" + url + ")",
});
break;
}
}
resolve(fetch(event.request));
});
})
);
});
|