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
7 changes: 0 additions & 7 deletions src/document_start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { createLogger } from './logger';

const log = createLogger();

const warmServiceWorker = (): void => {
chrome.runtime
.sendMessage({ contentScriptQuery: 'warmup' })
.catch(() => log.debug('Warm-up message went unanswered; the worker still booted'));
};

const captureUrlCartParam = (): void => {
if (!window.location.search.includes('bes_cart')) return;

Expand All @@ -30,5 +24,4 @@ const captureUrlCartParam = (): void => {
window.location.replace(newUrl);
};

warmServiceWorker();
captureUrlCartParam();
12 changes: 3 additions & 9 deletions test/document_start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@ const runDocumentStart = async () => {
await import('../src/document_start');
};

describe('document_start service worker warm-up', () => {
describe('document_start service worker messaging', () => {
beforeEach(() => {
mockSendMessage.mockClear();
});

it('pings the service worker so it boots ahead of document_end', async () => {
it('does not message the service worker, so nothing depends on it being awake', async () => {
setLocation('');

await runDocumentStart();

expect(mockSendMessage).toHaveBeenCalledWith({ contentScriptQuery: 'warmup' });
});

it('survives the ping going unanswered', async () => {
setLocation('');

await expect(runDocumentStart()).resolves.not.toThrow();
expect(mockSendMessage).not.toHaveBeenCalled();
});
});

Expand Down
Loading