diff --git a/front_end/core/sdk/ChildTargetManager.ts b/front_end/core/sdk/ChildTargetManager.ts index 111b8589df..cc1ee99a50 100644 --- a/front_end/core/sdk/ChildTargetManager.ts +++ b/front_end/core/sdk/ChildTargetManager.ts @@ -118,14 +118,14 @@ export class ChildTargetManager extends SDKModel implements Protocol let targetName = ''; if (targetInfo.type === 'worker' && targetInfo.title && targetInfo.title !== targetInfo.url) { targetName = targetInfo.title; - } else if (targetInfo.type !== 'iframe') { + } else if (targetInfo.type !== 'iframe' && targetInfo.type !== 'webview') { const parsedURL = Common.ParsedURL.ParsedURL.fromString(targetInfo.url); targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + (++ChildTargetManager.lastAnonymousTargetId); } let type = Type.Browser; - if (targetInfo.type === 'iframe') { + if (targetInfo.type === 'iframe' || targetInfo.type === 'webview') { type = Type.Frame; } // TODO(lfg): ensure proper capabilities for child pages (e.g. portals). diff --git a/front_end/core/sdk/DOMModel.ts b/front_end/core/sdk/DOMModel.ts index 35c0a99e90..4fea4123c8 100644 --- a/front_end/core/sdk/DOMModel.ts +++ b/front_end/core/sdk/DOMModel.ts @@ -159,14 +159,14 @@ export class DOMNode { this.childrenInternal = []; } + const frameOwnerTags = ['IFRAME', 'PORTAL', 'EMBED', 'OBJECT']; if (payload.contentDocument) { this.contentDocumentInternal = new DOMDocument(this.#domModelInternal, payload.contentDocument); this.contentDocumentInternal.parentNode = this; this.childrenInternal = []; - } else if ((payload.nodeName === 'IFRAME' || payload.nodeName === 'PORTAL') && payload.frameId) { + } else if (payload.frameId && frameOwnerTags.includes(payload.nodeName)) { // At this point we know we are in an OOPIF, otherwise #payload.contentDocument would have been set. - this.childDocumentPromiseForTesting = - this.createChildDocumentPromiseForTesting(payload.frameId, this.#domModelInternal.target()); + this.childDocumentPromiseForTesting = this.requestChildDocument(payload.frameId, this.#domModelInternal.target()); this.childrenInternal = []; } @@ -205,14 +205,10 @@ export class DOMNode { } } - private async createChildDocumentPromiseForTesting(frameId: Protocol.Page.FrameId, notInTarget: Target): - Promise { + private async requestChildDocument(frameId: Protocol.Page.FrameId, notInTarget: Target): Promise { const frame = await FrameManager.instance().getOrWaitForFrame(frameId, notInTarget); const childModel = frame.resourceTreeModel()?.target().model(DOMModel); - if (childModel) { - return childModel.requestDocument(); - } - return null; + return childModel?.requestDocument() || null; } isAdFrameNode(): boolean {