use-raw-call-func

This commit is contained in:
Yury Semikhatsky 2025-02-12 17:18:06 -08:00
parent 942b5aedc1
commit 53894f25b1
2 changed files with 10 additions and 10 deletions

View file

@ -156,6 +156,13 @@ export class BidiExecutionContext implements js.ExecutionContextDelegate {
throw new Error('Can\'t get remote object for nodeId');
}
async contentFrameIdForFrame(handle: dom.ElementHandle) {
const contentWindow = await this._rawCallFunction('e => e.contentWindow', { handle: handle._objectId });
if (contentWindow?.type === 'window')
return contentWindow.value.context;
return null;
}
async frameIdForWindowHandle(handle: js.JSHandle): Promise<string | null> {
if (!handle._objectId)
throw new Error('JSHandle is not a DOM node handle');

View file

@ -413,17 +413,10 @@ export class BidiPage implements PageDelegate {
async getContentFrame(handle: dom.ElementHandle): Promise<frames.Frame | null> {
const executionContext = toBidiExecutionContext(handle._context);
const contentWindow = await handle.evaluateHandle('e => e.contentWindow');
if (!contentWindow)
const frameId = await executionContext.contentFrameIdForFrame(handle);
if (!frameId)
return null;
try {
const frameId = await executionContext.frameIdForWindowHandle(contentWindow);
if (!frameId)
return null;
return this._page._frameManager.frame(frameId);
} finally {
contentWindow.dispose();
}
return this._page._frameManager.frame(frameId);
}
async getOwnerFrame(handle: dom.ElementHandle): Promise<string | null> {