blob: 6b43a3769637dcbc3574b7010ea5c93be73d7b00 (
plain)
1
2
3
4
5
6
7
8
9
|
const kURL = '/service-worker-interception-network-worker.js';
const kScript = 'postMessage("LOADED_FROM_SERVICE_WORKER")';
const kHeaders = [['content-type', 'text/javascript']];
self.addEventListener('fetch', e => {
// Serve a generated response for kURL.
if (e.request.url.indexOf(kURL) != -1)
e.respondWith(new Response(kScript, { headers: kHeaders }));
});
|