@@ -516,7 +516,16 @@ class FrameSession {
516
516
worldName : this . _crPage . utilityWorldName ,
517
517
} ) ,
518
518
this . _crPage . _networkManager . addSession ( this . _client , undefined , this . _isMainFrame ( ) ) ,
519
- this . _client . send ( 'Target.setAutoAttach' , { autoAttach : true , waitForDebuggerOnStart : true , flatten : true } ) ,
519
+ this . _client . send ( 'Target.setAutoAttach' , {
520
+ autoAttach : true ,
521
+ waitForDebuggerOnStart : true ,
522
+ flatten : true ,
523
+ filter : [
524
+ { type : 'iframe' } ,
525
+ { type : 'worker' } ,
526
+ { type : 'service_worker' , exclude : ! process . env . PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS }
527
+ ]
528
+ } ) ,
520
529
] ;
521
530
if ( ! isSettingStorageState ) {
522
531
if ( this . _crPage . _browserContext . needsPlaywrightBinding ( ) )
@@ -734,7 +743,15 @@ class FrameSession {
734
743
// TODO: attribute workers to the right frame.
735
744
this . _crPage . _networkManager . addSession ( session , this . _page . frameManager . frame ( this . _targetId ) ?? undefined ) . catch ( ( ) => { } ) ;
736
745
session . _sendMayFail ( 'Runtime.runIfWaitingForDebugger' ) ;
737
- session . _sendMayFail ( 'Target.setAutoAttach' , { autoAttach : true , waitForDebuggerOnStart : true , flatten : true } ) ;
746
+ session . _sendMayFail ( 'Target.setAutoAttach' , {
747
+ autoAttach : true ,
748
+ waitForDebuggerOnStart : true ,
749
+ flatten : true ,
750
+ filter : [
751
+ { type : 'worker' } ,
752
+ { type : 'service_worker' , exclude : ! process . env . PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS }
753
+ ]
754
+ } ) ;
738
755
session . on ( 'Target.attachedToTarget' , event => this . _onAttachedToTarget ( event ) ) ;
739
756
session . on ( 'Target.detachedFromTarget' , event => this . _onDetachedFromTarget ( event ) ) ;
740
757
session . on ( 'Runtime.consoleAPICalled' , event => {
0 commit comments