feat(Response): add Response.fromCache / Response.fromServiceWorker (#1971)

This patch:
- introduces `test/assets/cached` folder and teaches server to cache
  all the assets from the folder
- introduces `test/assets/serviceworkers` folder that stores all the
  service workers and makes them register with unique URL prefix
- introduces `Response.fromCache()` and `Response.fromServiceWorker()`
  methods

Fixes #1551.
This commit is contained in:
Andrey Lushnikov
2018-02-05 17:59:07 -05:00
committed by GitHub
parent 660b65780f
commit ecc3adc279
12 changed files with 140 additions and 15 deletions

View File

@@ -0,0 +1,3 @@
body {
background-color: pink;
}

View File

@@ -0,0 +1,2 @@
<link rel='stylesheet' href='./one-style.css'>
<div>hello, world!</div>

View File

@@ -0,0 +1,3 @@
<script>
window.registrationPromise = navigator.serviceWorker.register('sw.js');
</script>

View File

@@ -0,0 +1,3 @@
body {
background-color: pink;
}

View File

@@ -0,0 +1,4 @@
<link rel="stylesheet" href="./style.css">
<script>
navigator.serviceWorker.register('sw.js');
</script>

View File

@@ -0,0 +1,3 @@
self.addEventListener('fetch', event => {
event.respondWith(fetch(event.request));
});