Skip to content

Commit e95318a

Browse files
authored
chore(chromium): pass auto attach filter for iframes (microsoft#36784)
1 parent 6e7cdd5 commit e95318a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/playwright-core/src/server/chromium/crBrowser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class CRBrowser extends Browser {
151151
await Promise.all([...this._crPages.values()].map(crPage => crPage._page.waitForInitializedOrError()));
152152
}
153153

154-
_onAttachedToTarget({ targetInfo, sessionId, waitingForDebugger }: Protocol.Target.attachedToTargetPayload) {
154+
_onAttachedToTarget({ targetInfo, sessionId }: Protocol.Target.attachedToTargetPayload) {
155155
if (targetInfo.type === 'browser')
156156
return;
157157
const session = this._session.createChildSession(sessionId);

packages/playwright-core/src/server/chromium/crPage.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,16 @@ class FrameSession {
516516
worldName: this._crPage.utilityWorldName,
517517
}),
518518
this._crPage._networkManager.addSession(this._client, undefined, this._isMainFrame()),
519-
this._client.send('Target.setAutoAttach', { autoAttach: true, waitForDebuggerOnStart: true, flatten: true }),
519+
this._client.send('Target.setAutoAttach', {
520+
autoAttach: true,
521+
waitForDebuggerOnStart: true,
522+
flatten: true,
523+
filter: [
524+
{ type: 'iframe' },
525+
{ type: 'worker' },
526+
{ type: 'service_worker', exclude: !process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS }
527+
]
528+
}),
520529
];
521530
if (!isSettingStorageState) {
522531
if (this._crPage._browserContext.needsPlaywrightBinding())
@@ -734,7 +743,15 @@ class FrameSession {
734743
// TODO: attribute workers to the right frame.
735744
this._crPage._networkManager.addSession(session, this._page.frameManager.frame(this._targetId) ?? undefined).catch(() => {});
736745
session._sendMayFail('Runtime.runIfWaitingForDebugger');
737-
session._sendMayFail('Target.setAutoAttach', { autoAttach: true, waitForDebuggerOnStart: true, flatten: true });
746+
session._sendMayFail('Target.setAutoAttach', {
747+
autoAttach: true,
748+
waitForDebuggerOnStart: true,
749+
flatten: true,
750+
filter: [
751+
{ type: 'worker' },
752+
{ type: 'service_worker', exclude: !process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS }
753+
]
754+
});
738755
session.on('Target.attachedToTarget', event => this._onAttachedToTarget(event));
739756
session.on('Target.detachedFromTarget', event => this._onDetachedFromTarget(event));
740757
session.on('Runtime.consoleAPICalled', event => {

0 commit comments

Comments
 (0)