@@ -9,14 +9,13 @@ namespace PuppeteerSharp
99 internal class FrameManager
1010 {
1111 private readonly CDPSession _client ;
12- private readonly Page _page ;
1312 private Dictionary < int , ExecutionContext > _contextIdToContext ;
1413 private readonly ILogger _logger ;
1514
1615 internal FrameManager ( CDPSession client , FrameTree frameTree , Page page )
1716 {
1817 _client = client ;
19- _page = page ;
18+ Page = page ;
2019 Frames = new Dictionary < string , Frame > ( ) ;
2120 _contextIdToContext = new Dictionary < int , ExecutionContext > ( ) ;
2221 _logger = _client . Connection . LoggerFactory . CreateLogger < FrameManager > ( ) ;
@@ -34,16 +33,12 @@ internal FrameManager(CDPSession client, FrameTree frameTree, Page page)
3433
3534 internal Dictionary < string , Frame > Frames { get ; set ; }
3635 internal Frame MainFrame { get ; set ; }
36+ internal Page Page { get ; }
3737
3838 #endregion
3939
4040 #region Public Methods
4141
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-
4742 internal ExecutionContext ExecutionContextById ( int contextId )
4843 {
4944 _contextIdToContext . TryGetValue ( contextId , out var context ) ;
@@ -149,7 +144,6 @@ private void OnExecutionContextCreated(ContextPayload contextPayload)
149144 var context = new ExecutionContext (
150145 _client ,
151146 contextPayload ,
152- ( ctx , remoteObject ) => CreateJSHandle ( ctx , remoteObject ) ,
153147 frame ) ;
154148
155149 _contextIdToContext [ contextPayload . Id ] = context ;
@@ -199,7 +193,7 @@ private void OnFrameNavigated(FramePayload framePayload)
199193 else
200194 {
201195 // Initial main frame navigation.
202- frame = new Frame ( _client , null , framePayload . Id ) ;
196+ frame = new Frame ( this , _client , null , framePayload . Id ) ;
203197 }
204198
205199 Frames [ framePayload . Id ] = frame ;
@@ -248,7 +242,7 @@ private void OnFrameAttached(string frameId, string parentFrameId)
248242 if ( ! Frames . ContainsKey ( frameId ) && Frames . ContainsKey ( parentFrameId ) )
249243 {
250244 var parentFrame = Frames [ parentFrameId ] ;
251- var frame = new Frame ( _client , parentFrame , frameId ) ;
245+ var frame = new Frame ( this , _client , parentFrame , frameId ) ;
252246 Frames [ frame . Id ] = frame ;
253247 FrameAttached ? . Invoke ( this , new FrameEventArgs ( frame ) ) ;
254248 }
0 commit comments