chore(bidi): implement getOwnerFrame (#34755)

This commit is contained in:
Yury Semikhatsky 2025-02-12 10:53:03 -08:00 committed by GitHub
parent f54478a23e
commit 148af21540
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -423,7 +423,22 @@ export class BidiPage implements PageDelegate {
}
async getOwnerFrame(handle: dom.ElementHandle): Promise<string | null> {
throw new Error('Method not implemented.');
// TODO: switch to utility world?
const windowHandle = await handle.evaluateHandle(node => {
const doc = node.ownerDocument ?? node as Document;
return doc.defaultView;
});
if (!windowHandle)
return null;
if (!windowHandle._objectId)
return null;
const executionContext = toBidiExecutionContext(windowHandle._context as dom.FrameExecutionContext);
const contentWindow = await executionContext.rawCallFunction('e => e', { handle: windowHandle._objectId });
if (contentWindow.type === 'window') {
const frameId = contentWindow.value.context;
return frameId;
}
return null;
}
isElementHandle(remoteObject: bidi.Script.RemoteValue): boolean {