From dc25f67ba16e885b2136cbae85b265d79efc07ac Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Sun, 25 Nov 2018 21:54:15 -0600 Subject: [PATCH 1/2] tests: add smoketest for slow service worker --- .../test/fixtures/offline-ready-sw.js | 6 ++++- .../test/fixtures/offline-ready.html | 22 +++++++++++++++---- .../offline-local/offline-expectations.js | 13 +++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lighthouse-cli/test/fixtures/offline-ready-sw.js b/lighthouse-cli/test/fixtures/offline-ready-sw.js index 43dd5ac0e6c9..011715dc6bd9 100644 --- a/lighthouse-cli/test/fixtures/offline-ready-sw.js +++ b/lighthouse-cli/test/fixtures/offline-ready-sw.js @@ -24,7 +24,11 @@ const RUNTIME = 'runtime'; // The install handler takes care of precaching the resources we always need. self.addEventListener('install', event => { - self.skipWaiting(); + if (self.location.search.includes('slow')) { + event.waitUntil(new Promise(resolve => setTimeout(resolve, 5000))); + } else { + self.skipWaiting(); + } const populateCaches = caches.open(PRECACHE) .then(cache => cache.addAll(PRECACHE_URLS)); diff --git a/lighthouse-cli/test/fixtures/offline-ready.html b/lighthouse-cli/test/fixtures/offline-ready.html index bac166961949..5f3ed31c5611 100644 --- a/lighthouse-cli/test/fixtures/offline-ready.html +++ b/lighthouse-cli/test/fixtures/offline-ready.html @@ -24,18 +24,32 @@