blob: 6ddbc3d5c184ed13e4939f9279f7f48538eff344 (
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
|
const SERVICEWORKER_DOC = `<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script src="utils.js" type="text/javascript"></script>
</head>
<body>
SERVICEWORKER
</body>
</html>
`;
const SERVICEWORKER_RESPONSE = new Response(SERVICEWORKER_DOC, {
headers: { "content-type": "text/html" },
});
addEventListener("fetch", event => {
// Allow utils.js which we explicitly include to be loaded by resetting
// interception.
if (event.request.url.endsWith("/utils.js")) {
return;
}
event.respondWith(SERVICEWORKER_RESPONSE.clone());
});
|