Correctly show contentDocument of OOPIFs created by <embed> and <object>

This implement handling for frame owner elements like <embed> and <object>
consistent with the way we handle iframes.

- treat "webview" targets similarly to iframes;
- request child document for <embed> and <object> elements in addition to <iframe>
- (drive-by) createChildDocumentPromiseForTesting => requestChildDocument, because
it's not specific to testing.

Bug: 1250673
Change-Id: I183ae0e55fee0368721cf401c8a7d5148bed071c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3235721
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
Andrey Kosyakov
2021-10-21 18:39:15 +00:00
committed by Devtools-frontend LUCI CQ
parent 3c3302dc25
commit 1139798e6b
2 changed files with 7 additions and 11 deletions
+2 -2
View File
@@ -118,14 +118,14 @@ export class ChildTargetManager extends SDKModel<EventTypes> 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).
+5 -9
View File
@@ -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<DOMDocument|null> {
private async requestChildDocument(frameId: Protocol.Page.FrameId, notInTarget: Target): Promise<DOMDocument|null> {
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 {