@@ -195,7 +195,8 @@ export class BidiPage implements PageDelegate {
195195
196196 private _onNavigationCommitted ( params : bidi . BrowsingContext . NavigationInfo ) {
197197 const frameId = params . context ;
198- this . _page . frameManager . frameCommittedNewDocumentNavigation ( frameId , params . url , '' , params . navigation ! , /* initial */ false ) ;
198+ const frame = this . _page . frameManager . frame ( frameId ) ! ;
199+ this . _page . frameManager . frameCommittedNewDocumentNavigation ( frameId , params . url , frame . _name , params . navigation ! , /* initial */ false ) ;
199200 }
200201
201202 private _onDomContentLoaded ( params : bidi . BrowsingContext . NavigationInfo ) {
@@ -582,24 +583,24 @@ export class BidiPage implements PageDelegate {
582583 const parent = frame . parentFrame ( ) ;
583584 if ( ! parent )
584585 throw new Error ( 'Frame has been detached.' ) ;
585- const parentContext = await parent . _mainContext ( ) ;
586- const list = await parentContext . evaluateHandle ( ( ) => { return [ ...document . querySelectorAll ( 'iframe,frame' ) ] ; } ) ;
587- const length = await list . evaluate ( list => list . length ) ;
588- let foundElement = null ;
589- for ( let i = 0 ; i < length ; i ++ ) {
590- const element = await list . evaluateHandle ( ( list , i ) => list [ i ] , i ) ;
591- const candidate = await element . contentFrame ( ) ;
592- if ( frame === candidate ) {
593- foundElement = element ;
594- break ;
595- } else {
596- element . dispose ( ) ;
597- }
598- }
599- list . dispose ( ) ;
600- if ( ! foundElement )
586+ const node = await this . _getFrameNode ( frame ) ;
587+ if ( ! node ?. sharedId )
601588 throw new Error ( 'Frame has been detached.' ) ;
602- return foundElement ;
589+ const parentFrameExecutionContext = await parent . _mainContext ( ) ;
590+ return await toBidiExecutionContext ( parentFrameExecutionContext ) . remoteObjectForNodeId ( parentFrameExecutionContext , { sharedId : node . sharedId } ) ;
591+ }
592+
593+ async _getFrameNode ( frame : frames . Frame ) : Promise < bidi . Script . NodeRemoteValue | undefined > {
594+ const parent = frame . parentFrame ( ) ;
595+ if ( ! parent )
596+ return undefined ;
597+
598+ const result = await this . _session . send ( 'browsingContext.locateNodes' , {
599+ context : parent . _id ,
600+ locator : { type : 'context' , value : { context : frame . _id } } ,
601+ } ) ;
602+ const node = result . nodes [ 0 ] ;
603+ return node ;
603604 }
604605
605606 shouldToggleStyleSheetToSyncAnimations ( ) : boolean {
0 commit comments