Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(chromium): attribute worker to the right frame (#41116)

Dmitry Gozman205a006a7d55
diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.ts
index 907f4a4790..19556b0536 100644
--- a/packages/playwright-core/src/server/chromium/crPage.ts
+++ b/packages/playwright-core/src/server/chromium/crPage.ts
@@ -741,8 +741,7 @@ class FrameSession {
worker.workerScriptLoaded();
// This might fail if the target is closed before we initialize.
session._sendMayFail('Runtime.enable');
- // TODO: attribute workers to the right frame.
- this._crPage._networkManager.addSession(session, this._page.frameManager.frame(this._targetId) ?? undefined).catch(() => {});
+ this._crPage._networkManager.addSession(session, this._page.frameManager.frame(event.targetInfo.parentFrameId ?? this._targetId) ?? undefined).catch(() => {});
session._sendMayFail('Runtime.runIfWaitingForDebugger');
session._sendMayFail('Target.setAutoAttach', { autoAttach: true, waitForDebuggerOnStart: true, flatten: true });
session.on('Target.attachedToTarget', event => this._onAttachedToTarget(event));
diff --git a/tests/page/workers.spec.ts b/tests/page/workers.spec.ts
index 617f376673..59477ac93c 100644
--- a/tests/page/workers.spec.ts
+++ b/tests/page/workers.spec.ts
@@ -188,7 +188,6 @@ it('should clear upon cross-process navigation', async function({ server, page }
});
it('should attribute network activity for worker inside iframe to the iframe', async function({ page, server, browserName, browserMajorVersion }) {
- it.fixme(browserName === 'chromium');
it.skip(browserName === 'firefox' && browserMajorVersion < 114, 'https://github.com/microsoft/playwright/issues/21760');
await page.goto(server.PREFIX + '/empty.html');