@@ -39,21 +39,20 @@ internal FrameManager(CDPSession client, FrameTree frameTree, Page page)
3939
4040 #region Public Methods
4141
42- internal JSHandle CreateJSHandle ( int contextId , dynamic remoteObject )
42+ internal JSHandle CreateJSHandle ( ExecutionContext context , dynamic remoteObject )
43+ => remoteObject . subtype == "node"
44+ ? new ElementHandle ( context , _client , remoteObject , _page , this )
45+ : new JSHandle ( context , _client , remoteObject ) ;
46+
47+ internal ExecutionContext ExecutionContextById ( int contextId )
4348 {
44- _contextIdToContext . TryGetValue ( contextId , out var storedContext ) ;
49+ _contextIdToContext . TryGetValue ( contextId , out var context ) ;
4550
46- if ( storedContext == null )
51+ if ( context == null )
4752 {
4853 _logger . LogError ( "INTERNAL ERROR: missing context with id = {ContextId}" , contextId ) ;
4954 }
50-
51- if ( remoteObject . subtype == "node" )
52- {
53- return new ElementHandle ( storedContext , _client , remoteObject , _page , this ) ;
54- }
55-
56- return new JSHandle ( storedContext , _client , remoteObject ) ;
55+ return context ;
5756 }
5857
5958 #endregion
@@ -150,7 +149,7 @@ private void OnExecutionContextCreated(ContextPayload contextPayload)
150149 var context = new ExecutionContext (
151150 _client ,
152151 contextPayload ,
153- ( ctx , remoteObject ) => CreateJSHandle ( contextPayload . Id , remoteObject ) ,
152+ ( ctx , remoteObject ) => CreateJSHandle ( ctx , remoteObject ) ,
154153 frame ) ;
155154
156155 _contextIdToContext [ contextPayload . Id ] = context ;
0 commit comments