summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/fetch/https/https_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/fetch/https/https_test.js')
-rw-r--r--dom/serviceworkers/test/fetch/https/https_test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/fetch/https/https_test.js b/dom/serviceworkers/test/fetch/https/https_test.js
new file mode 100644
index 0000000000..5f20690bb5
--- /dev/null
+++ b/dom/serviceworkers/test/fetch/https/https_test.js
@@ -0,0 +1,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" } }
+ )
+ );
+ }
+});