test: another attempt to fix sw test #2201
This commit is contained in:
parent
150e5a9bbf
commit
c4b1ac99b0
@ -1,4 +1,5 @@
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<script>
|
||||
window.registrationPromise = navigator.serviceWorker.register('sw.js');
|
||||
window.activationPromise = new Promise(resolve => navigator.serviceWorker.oncontrollerchange = resolve);
|
||||
</script>
|
||||
|
@ -1,3 +1,7 @@
|
||||
self.addEventListener('fetch', event => {
|
||||
event.respondWith(fetch(event.request));
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
||||
|
@ -2855,7 +2855,7 @@ describe('Page', function() {
|
||||
|
||||
// Load and re-load to make sure serviceworker is installed and running.
|
||||
await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html', {waitUntil: 'networkidle2'});
|
||||
await page.evaluate(async() => await window.registrationPromise);
|
||||
await page.evaluate(async() => await window.activationPromise);
|
||||
await page.reload();
|
||||
|
||||
expect(responses.size).toBe(2);
|
||||
@ -3766,6 +3766,7 @@ describe('Page', function() {
|
||||
it('should report when a service worker is created and destroyed', async({page, server, browser}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const createdTarget = new Promise(fulfill => browser.once('targetcreated', target => fulfill(target)));
|
||||
|
||||
await page.goto(server.PREFIX + '/serviceworkers/empty/sw.html');
|
||||
|
||||
expect((await createdTarget).type()).toBe('service_worker');
|
||||
|
Loading…
Reference in New Issue
Block a user