feat(chromium): allow attaching to other targets as to pages (#14873)

This commit is contained in:
Pavel Feldman 2022-06-15 08:31:32 -08:00 committed by GitHub
parent 112a18e083
commit 464cbb7457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,7 +161,9 @@ export class CRBrowser extends Browser {
return; return;
} }
if (targetInfo.type === 'other' || !context) { const treatOtherAsPage = targetInfo.type === 'other' && process.env.PW_CHROMIUM_ATTACH_TO_OTHER;
if (!context || (targetInfo.type === 'other' && !treatOtherAsPage)) {
if (waitingForDebugger) { if (waitingForDebugger) {
// Ideally, detaching should resume any target, but there is a bug in the backend. // Ideally, detaching should resume any target, but there is a bug in the backend.
session._sendMayFail('Runtime.runIfWaitingForDebugger').then(() => { session._sendMayFail('Runtime.runIfWaitingForDebugger').then(() => {
@ -181,9 +183,9 @@ export class CRBrowser extends Browser {
return; return;
} }
if (targetInfo.type === 'page') { if (targetInfo.type === 'page' || treatOtherAsPage) {
const opener = targetInfo.openerId ? this._crPages.get(targetInfo.openerId) || null : null; const opener = targetInfo.openerId ? this._crPages.get(targetInfo.openerId) || null : null;
const crPage = new CRPage(session, targetInfo.targetId, context, opener, { hasUIWindow: true, isBackgroundPage: false }); const crPage = new CRPage(session, targetInfo.targetId, context, opener, { hasUIWindow: targetInfo.type === 'page', isBackgroundPage: false });
this._crPages.set(targetInfo.targetId, crPage); this._crPages.set(targetInfo.targetId, crPage);
return; return;
} }