diff --git a/public/offline.html b/public/offline.html index 78fee9ea..2e2dd09d 100644 --- a/public/offline.html +++ b/public/offline.html @@ -113,8 +113,9 @@

You're offline

}); if (!response.ok) throw new Error('Connection unavailable'); const manifest = await response.json(); - if (typeof manifest?.name !== 'string' || typeof manifest?.start_url !== 'string') { - throw new Error('Invalid response'); + if (manifest?.name !== 'ePlus OnAir — Listen Beyond Borders.' + || manifest?.start_url !== '../' || manifest?.scope !== '../') { + throw new Error('Unexpected website manifest'); } restored = true; diff --git a/tests/pwa-reconnect.test.mjs b/tests/pwa-reconnect.test.mjs index ef25d466..a1a61085 100644 --- a/tests/pwa-reconnect.test.mjs +++ b/tests/pwa-reconnect.test.mjs @@ -7,8 +7,11 @@ const read = path => readFile(new URL('../' + path, import.meta.url), 'utf8'); async function offlinePageHarness({ reachable = false, hidden = false, validManifest = true, serviceWorkerFails = false } = {}) { const html = await read('public/offline.html'); - const script = html.match(/', start); + assert.ok(start >= 0 && end > start, 'offline page must contain a self-contained reconnect script'); + const script = html.slice(start + openingTag.length, end); const state = { reachable, validManifest }; const windowEvents = new Map(); @@ -58,7 +61,7 @@ async function offlinePageHarness({ reachable = false, hidden = false, validMani return { ok: true, json: async () => state.validManifest - ? { name: 'ePlus OnAir', start_url: '../' } + ? { name: 'ePlus OnAir — Listen Beyond Borders.', start_url: '../', scope: '../' } : { unexpected: 'captive portal' }, }; },