@@ -50,51 +50,49 @@ export interface IgnoreListGeneralRules {
5050
5151export class IgnoreListManager extends Common . ObjectWrapper . ObjectWrapper < EventTypes > implements
5252 SDK . TargetManager . SDKModelObserver < SDK . DebuggerModel . DebuggerModel > {
53- readonly #listeners: Set < ( ) => void > ;
54- readonly #isIgnoreListedURLCache: Map < string , boolean > ;
55- readonly #contentScriptExecutionContexts: Set < string > ;
53+ readonly #settings: Common . Settings . Settings ;
54+ readonly #targetManager: SDK . TargetManager . TargetManager ;
5655
57- private constructor ( ) {
56+ readonly #listeners = new Set < ( ) => void > ( ) ;
57+ readonly #isIgnoreListedURLCache = new Map < string , boolean > ( ) ;
58+ readonly #contentScriptExecutionContexts = new Set < string > ( ) ;
59+
60+ private constructor ( settings : Common . Settings . Settings , targetManager : SDK . TargetManager . TargetManager ) {
5861 super ( ) ;
62+ this . #settings = settings ;
63+ this . #targetManager = targetManager ;
5964
60- SDK . TargetManager . TargetManager . instance ( ) . addModelListener (
65+ this . #targetManager . addModelListener (
6166 SDK . DebuggerModel . DebuggerModel , SDK . DebuggerModel . Events . GlobalObjectCleared ,
6267 this . clearCacheIfNeeded . bind ( this ) , this ) ;
63- SDK . TargetManager . TargetManager . instance ( ) . addModelListener (
68+ this . #targetManager . addModelListener (
6469 SDK . RuntimeModel . RuntimeModel , SDK . RuntimeModel . Events . ExecutionContextCreated , this . onExecutionContextCreated ,
6570 this , { scoped : true } ) ;
66- SDK . TargetManager . TargetManager . instance ( ) . addModelListener (
71+ this . #targetManager . addModelListener (
6772 SDK . RuntimeModel . RuntimeModel , SDK . RuntimeModel . Events . ExecutionContextDestroyed ,
6873 this . onExecutionContextDestroyed , this , { scoped : true } ) ;
69- Common . Settings . Settings . instance ( )
70- . moduleSetting ( 'skip-stack-frames-pattern' )
71- . addChangeListener ( this . patternChanged . bind ( this ) ) ;
72- Common . Settings . Settings . instance ( )
73- . moduleSetting ( 'skip-content-scripts' )
74- . addChangeListener ( this . patternChanged . bind ( this ) ) ;
75- Common . Settings . Settings . instance ( )
76- . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' )
77- . addChangeListener ( this . patternChanged . bind ( this ) ) ;
78- Common . Settings . Settings . instance ( )
79- . moduleSetting ( 'enable-ignore-listing' )
74+ this . #settings. moduleSetting ( 'skip-stack-frames-pattern' ) . addChangeListener ( this . patternChanged . bind ( this ) ) ;
75+ this . #settings. moduleSetting ( 'skip-content-scripts' ) . addChangeListener ( this . patternChanged . bind ( this ) ) ;
76+ this . #settings. moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' )
8077 . addChangeListener ( this . patternChanged . bind ( this ) ) ;
81- Common . Settings . Settings . instance ( )
82- . moduleSetting ( 'skip-anonymous-scripts' )
83- . addChangeListener ( this . patternChanged . bind ( this ) ) ;
84-
85- this . #listeners = new Set ( ) ;
86- this . #isIgnoreListedURLCache = new Map ( ) ;
87- this . #contentScriptExecutionContexts = new Set ( ) ;
78+ this . #settings. moduleSetting ( 'enable-ignore-listing' ) . addChangeListener ( this . patternChanged . bind ( this ) ) ;
79+ this . #settings. moduleSetting ( 'skip-anonymous-scripts' ) . addChangeListener ( this . patternChanged . bind ( this ) ) ;
8880
89- SDK . TargetManager . TargetManager . instance ( ) . observeModels ( SDK . DebuggerModel . DebuggerModel , this ) ;
81+ this . #targetManager . observeModels ( SDK . DebuggerModel . DebuggerModel , this ) ;
9082 }
9183
9284 static instance ( opts : {
9385 forceNew : boolean | null ,
94- } = { forceNew : null } ) : IgnoreListManager {
86+ settings ?: Common . Settings . Settings ,
87+ targetManager ?: SDK . TargetManager . TargetManager ,
88+ } = {
89+ forceNew : null ,
90+ } ) : IgnoreListManager {
9591 const { forceNew} = opts ;
9692 if ( ! ignoreListManagerInstance || forceNew ) {
97- ignoreListManagerInstance = new IgnoreListManager ( ) ;
93+ ignoreListManagerInstance = new IgnoreListManager (
94+ opts . settings ?? Common . Settings . Settings . instance ( ) ,
95+ opts . targetManager ?? SDK . TargetManager . TargetManager . instance ( ) ) ;
9896 }
9997
10098 return ignoreListManagerInstance ;
@@ -135,8 +133,7 @@ export class IgnoreListManager extends Common.ObjectWrapper.ObjectWrapper<EventT
135133 if ( this . isContentScript ( event . data ) ) {
136134 this . #contentScriptExecutionContexts. add ( event . data . uniqueId ) ;
137135 if ( this . skipContentScripts ) {
138- for ( const debuggerModel of SDK . TargetManager . TargetManager . instance ( ) . models (
139- SDK . DebuggerModel . DebuggerModel ) ) {
136+ for ( const debuggerModel of this . #targetManager. models ( SDK . DebuggerModel . DebuggerModel ) ) {
140137 void this . updateIgnoredExecutionContexts ( debuggerModel ) ;
141138 }
142139 }
@@ -148,8 +145,7 @@ export class IgnoreListManager extends Common.ObjectWrapper.ObjectWrapper<EventT
148145 if ( this . isContentScript ( event . data ) ) {
149146 this . #contentScriptExecutionContexts. delete ( event . data . uniqueId ) ;
150147 if ( this . skipContentScripts ) {
151- for ( const debuggerModel of SDK . TargetManager . TargetManager . instance ( ) . models (
152- SDK . DebuggerModel . DebuggerModel ) ) {
148+ for ( const debuggerModel of this . #targetManager. models ( SDK . DebuggerModel . DebuggerModel ) ) {
153149 void this . updateIgnoredExecutionContexts ( debuggerModel ) ;
154150 }
155151 }
@@ -163,8 +159,7 @@ export class IgnoreListManager extends Common.ObjectWrapper.ObjectWrapper<EventT
163159 }
164160
165161 private getSkipStackFramesPatternSetting ( ) : Common . Settings . RegExpSetting {
166- return Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-stack-frames-pattern' ) as
167- Common . Settings . RegExpSetting ;
162+ return this . #settings. moduleSetting ( 'skip-stack-frames-pattern' ) as Common . Settings . RegExpSetting ;
168163 }
169164
170165 private setIgnoreListPatterns ( debuggerModel : SDK . DebuggerModel . DebuggerModel ) : Promise < boolean > {
@@ -327,58 +322,57 @@ export class IgnoreListManager extends Common.ObjectWrapper.ObjectWrapper<EventT
327322 }
328323
329324 get enableIgnoreListing ( ) : boolean {
330- return Common . Settings . Settings . instance ( ) . moduleSetting ( 'enable-ignore-listing' ) . get ( ) ;
325+ return this . #settings . moduleSetting ( 'enable-ignore-listing' ) . get ( ) ;
331326 }
332327
333328 set enableIgnoreListing ( value : boolean ) {
334- Common . Settings . Settings . instance ( ) . moduleSetting ( 'enable-ignore-listing' ) . set ( value ) ;
329+ this . #settings . moduleSetting ( 'enable-ignore-listing' ) . set ( value ) ;
335330 }
336331
337332 get skipContentScripts ( ) : boolean {
338- return this . enableIgnoreListing && Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-content-scripts' ) . get ( ) ;
333+ return this . enableIgnoreListing && this . #settings . moduleSetting ( 'skip-content-scripts' ) . get ( ) ;
339334 }
340335
341336 get skipAnonymousScripts ( ) : boolean {
342- return this . enableIgnoreListing &&
343- Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-anonymous-scripts' ) . get ( ) ;
337+ return this . enableIgnoreListing && this . #settings. moduleSetting ( 'skip-anonymous-scripts' ) . get ( ) ;
344338 }
345339
346340 get automaticallyIgnoreListKnownThirdPartyScripts ( ) : boolean {
347341 return this . enableIgnoreListing &&
348- Common . Settings . Settings . instance ( ) . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . get ( ) ;
342+ this . #settings . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . get ( ) ;
349343 }
350344
351345 ignoreListContentScripts ( ) : void {
352346 if ( ! this . enableIgnoreListing ) {
353347 this . enableIgnoreListing = true ;
354348 }
355- Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-content-scripts' ) . set ( true ) ;
349+ this . #settings . moduleSetting ( 'skip-content-scripts' ) . set ( true ) ;
356350 }
357351
358352 unIgnoreListContentScripts ( ) : void {
359- Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-content-scripts' ) . set ( false ) ;
353+ this . #settings . moduleSetting ( 'skip-content-scripts' ) . set ( false ) ;
360354 }
361355
362356 ignoreListAnonymousScripts ( ) : void {
363357 if ( ! this . enableIgnoreListing ) {
364358 this . enableIgnoreListing = true ;
365359 }
366- Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-anonymous-scripts' ) . set ( true ) ;
360+ this . #settings . moduleSetting ( 'skip-anonymous-scripts' ) . set ( true ) ;
367361 }
368362
369363 unIgnoreListAnonymousScripts ( ) : void {
370- Common . Settings . Settings . instance ( ) . moduleSetting ( 'skip-anonymous-scripts' ) . set ( false ) ;
364+ this . #settings . moduleSetting ( 'skip-anonymous-scripts' ) . set ( false ) ;
371365 }
372366
373367 ignoreListThirdParty ( ) : void {
374368 if ( ! this . enableIgnoreListing ) {
375369 this . enableIgnoreListing = true ;
376370 }
377- Common . Settings . Settings . instance ( ) . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . set ( true ) ;
371+ this . #settings . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . set ( true ) ;
378372 }
379373
380374 unIgnoreListThirdParty ( ) : void {
381- Common . Settings . Settings . instance ( ) . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . set ( false ) ;
375+ this . #settings . moduleSetting ( 'automatically-ignore-list-known-third-party-scripts' ) . set ( false ) ;
382376 }
383377
384378 ignoreListURL ( url : Platform . DevToolsPath . UrlString ) : void {
@@ -467,7 +461,7 @@ export class IgnoreListManager extends Common.ObjectWrapper.ObjectWrapper<EventT
467461 this . #isIgnoreListedURLCache. clear ( ) ;
468462
469463 const promises : Array < Promise < unknown > > = [ ] ;
470- for ( const debuggerModel of SDK . TargetManager . TargetManager . instance ( ) . models ( SDK . DebuggerModel . DebuggerModel ) ) {
464+ for ( const debuggerModel of this . #targetManager . models ( SDK . DebuggerModel . DebuggerModel ) ) {
471465 promises . push ( this . setIgnoreListPatterns ( debuggerModel ) ) ;
472466 const sourceMapManager = debuggerModel . sourceMapManager ( ) ;
473467 for ( const script of debuggerModel . scripts ( ) ) {
0 commit comments