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