@@ -21,7 +21,7 @@ public class Browser : IBrowser
2121
2222 private readonly ConcurrentDictionary < string , BrowserContext > _contexts ;
2323 private readonly ILogger < Browser > _logger ;
24- private readonly Func < TargetInfo , bool > _targetFilterCallback ;
24+ private readonly Func < Target , bool > _targetFilterCallback ;
2525 private readonly BrowserContext _defaultContext ;
2626 private readonly CustomQueriesManager _customQueriesManager = new ( ) ;
2727 private Task _closeTask ;
@@ -33,18 +33,18 @@ internal Browser(
3333 bool ignoreHTTPSErrors ,
3434 ViewPortOptions defaultViewport ,
3535 LauncherBase launcher ,
36- Func < TargetInfo , bool > targetFilter = null ,
37- Func < TargetInfo , bool > isPageTargetFunc = null )
36+ Func < Target , bool > targetFilter = null ,
37+ Func < Target , bool > isPageTargetFunc = null )
3838 {
3939 IgnoreHTTPSErrors = ignoreHTTPSErrors ;
4040 DefaultViewport = defaultViewport ;
4141 Launcher = launcher ;
4242 Connection = connection ;
43- _targetFilterCallback = targetFilter ?? ( ( TargetInfo _ ) => true ) ;
43+ _targetFilterCallback = targetFilter ?? ( ( Target _ ) => true ) ;
4444 _logger = Connection . LoggerFactory . CreateLogger < Browser > ( ) ;
4545 IsPageTargetFunc =
4646 isPageTargetFunc ??
47- new Func < TargetInfo , bool > ( ( TargetInfo target ) =>
47+ new Func < Target , bool > ( ( Target target ) =>
4848 {
4949 return
5050 target . Type == TargetType . Page ||
@@ -139,7 +139,7 @@ public bool IsClosed
139139
140140 internal ITargetManager TargetManager { get ; }
141141
142- internal Func < TargetInfo , bool > IsPageTargetFunc { get ; set ; }
142+ internal Func < Target , bool > IsPageTargetFunc { get ; set ; }
143143
144144 /// <inheritdoc/>
145145 public Task < IPage > NewPageAsync ( ) => _defaultContext . NewPageAsync ( ) ;
@@ -269,8 +269,8 @@ internal static async Task<Browser> CreateAsync(
269269 bool ignoreHTTPSErrors ,
270270 ViewPortOptions defaultViewPort ,
271271 LauncherBase launcher ,
272- Func < TargetInfo , bool > targetFilter = null ,
273- Func < TargetInfo , bool > isPageTargetCallback = null ,
272+ Func < Target , bool > targetFilter = null ,
273+ Func < Target , bool > isPageTargetCallback = null ,
274274 Action < IBrowser > initAction = null )
275275 {
276276 var browser = new Browser (
@@ -475,7 +475,14 @@ private Target CreateTarget(TargetInfo targetInfo, CDPSession session)
475475
476476 Func < bool , Task < CDPSession > > createSession = ( bool isAutoAttachEmulated ) => Connection . CreateSessionAsync ( targetInfo , isAutoAttachEmulated ) ;
477477
478- if ( IsPageTargetFunc ( targetInfo ) )
478+ var otherTarget = new OtherTarget (
479+ targetInfo ,
480+ session ,
481+ context ,
482+ TargetManager ,
483+ createSession ) ;
484+
485+ if ( IsPageTargetFunc ( otherTarget ) )
479486 {
480487 return new PageTarget (
481488 targetInfo ,
@@ -498,12 +505,7 @@ private Target CreateTarget(TargetInfo targetInfo, CDPSession session)
498505 createSession ) ;
499506 }
500507
501- return new OtherTarget (
502- targetInfo ,
503- session ,
504- context ,
505- TargetManager ,
506- createSession ) ;
508+ return otherTarget ;
507509 }
508510 }
509511}
0 commit comments