-
Notifications
You must be signed in to change notification settings - Fork 54
/
https_test.js
31 lines (30 loc) · 1.07 KB
/
https_test.js
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
self.addEventListener("install", function(event) {
event.waitUntil(
caches.open("cache").then(function(cache) {
var synth = new Response(
'<!DOCTYPE html><script>window.parent.postMessage({status: "done-synth-sw"}, "*");</script>',
{ headers: { "Content-Type": "text/html" } }
);
return Promise.all([
cache.add("index.html"),
cache.put("synth-sw.html", synth),
]);
})
);
});
self.addEventListener("fetch", function(event) {
if (event.request.url.includes("index.html")) {
event.respondWith(caches.match(event.request));
} else if (event.request.url.includes("synth-sw.html")) {
event.respondWith(caches.match(event.request));
} else if (event.request.url.includes("synth-window.html")) {
event.respondWith(caches.match(event.request));
} else if (event.request.url.includes("synth.html")) {
event.respondWith(
new Response(
'<!DOCTYPE html><script>window.parent.postMessage({status: "done-synth"}, "*");</script>',
{ headers: { "Content-Type": "text/html" } }
)
);
}
});