Skip to content

Commit

Permalink
fix: service workers no longer their pages
Browse files Browse the repository at this point in the history
See: #1 (comment)

Fixes: #1
  • Loading branch information
ruifigueira committed Nov 10, 2023
1 parent 85d4872 commit 5b66911
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/server/transport/crxTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class CrxTransport implements ConnectionTransport {
if (message.method === 'Target.setAutoAttach' && !tabId) {
// no tab to attach, just skip for now...
result = await Promise.resolve().then();
} else if (message.method === 'Target.setAutoAttach') {
// we need to exclude service workers, see https://github.com/ruifigueira/playwright-crx/issues/1
result = await this._send(message.method, { tabId, ...message.params, filter: [{ exclude: true, type: 'service_worker' }] });
} else if (message.method === 'Target.getTargetInfo' && !tabId) {
// most likely related with https://chromium-review.googlesource.com/c/chromium/src/+/2885888
// See CRBrowser.connect
Expand Down
7 changes: 7 additions & 0 deletions tests/crx/crx-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,10 @@ test.fixme('should remove page if tab is externally detached',async ({ runCrxTes
expect(crxApp.pages()).not.toContain(page);
});
});

test('should not block on pages with service workers', async ({ runCrxTest }) => {
await runCrxTest(async ({ expect, page, server }) => {
await page.goto(`${server.PREFIX}/serviceworkers/empty/sw.html`);
await expect(page.evaluate(() => window['registrationPromise'])).resolves.toBeTruthy();
});
});

0 comments on commit 5b66911

Please sign in to comment.