From c4b1ac99b0099ae6cb291fa11ff19e1eaeab1ff6 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 15 Mar 2018 16:58:02 -0700 Subject: [PATCH] test: another attempt to fix sw test #2201 --- test/assets/serviceworkers/fetch/sw.html | 1 + test/assets/serviceworkers/fetch/sw.js | 4 ++++ test/test.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/assets/serviceworkers/fetch/sw.html b/test/assets/serviceworkers/fetch/sw.html index ee930cf443f..a9d28acb097 100644 --- a/test/assets/serviceworkers/fetch/sw.html +++ b/test/assets/serviceworkers/fetch/sw.html @@ -1,4 +1,5 @@ diff --git a/test/assets/serviceworkers/fetch/sw.js b/test/assets/serviceworkers/fetch/sw.js index 79eb23e63ae..d44c7eab946 100644 --- a/test/assets/serviceworkers/fetch/sw.js +++ b/test/assets/serviceworkers/fetch/sw.js @@ -1,3 +1,7 @@ self.addEventListener('fetch', event => { event.respondWith(fetch(event.request)); }); + +self.addEventListener('activate', event => { + event.waitUntil(clients.claim()); +}); diff --git a/test/test.js b/test/test.js index d1e7475fe64..ba5a5b8d511 100644 --- a/test/test.js +++ b/test/test.js @@ -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');