Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions public/offline.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ <h1 id="offline-title">You're offline</h1>
});
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;
Expand Down
9 changes: 6 additions & 3 deletions tests/pwa-reconnect.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<script>([\s\S]*?)<\/script>/)?.[1];
assert.ok(script, 'offline page must contain a self-contained reconnect script');
const openingTag = '<script>';
const start = html.indexOf(openingTag);
const end = html.indexOf('</script>', 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();
Expand Down Expand Up @@ -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' },
};
},
Expand Down
Loading