mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
3
test/assets/cached/one-style.css
Normal file
3
test/assets/cached/one-style.css
Normal file
@@ -0,0 +1,3 @@
|
||||
body {
|
||||
background-color: pink;
|
||||
}
|
||||
2
test/assets/cached/one-style.html
Normal file
2
test/assets/cached/one-style.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<link rel='stylesheet' href='./one-style.css'>
|
||||
<div>hello, world!</div>
|
||||
3
test/assets/serviceworkers/empty/sw.html
Normal file
3
test/assets/serviceworkers/empty/sw.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<script>
|
||||
window.registrationPromise = navigator.serviceWorker.register('sw.js');
|
||||
</script>
|
||||
3
test/assets/serviceworkers/fetch/style.css
Normal file
3
test/assets/serviceworkers/fetch/style.css
Normal file
@@ -0,0 +1,3 @@
|
||||
body {
|
||||
background-color: pink;
|
||||
}
|
||||
4
test/assets/serviceworkers/fetch/sw.html
Normal file
4
test/assets/serviceworkers/fetch/sw.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<script>
|
||||
navigator.serviceWorker.register('sw.js');
|
||||
</script>
|
||||
3
test/assets/serviceworkers/fetch/sw.js
Normal file
3
test/assets/serviceworkers/fetch/sw.js
Normal file
@@ -0,0 +1,3 @@
|
||||
self.addEventListener('fetch', event => {
|
||||
event.respondWith(fetch(event.request));
|
||||
});
|
||||
Reference in New Issue
Block a user