@@ -49,8 +49,8 @@ export class McpContext implements Context {
4949 #consoleCollector: PageCollector < ConsoleMessage | Error > ;
5050
5151 #isRunningTrace = false ;
52- #networkConditions: string | null = null ;
53- #cpuThrottlingRate = 1 ;
52+ #networkConditionsMap = new WeakMap < Page , string > ( ) ;
53+ #cpuThrottlingRateMap = new WeakMap < Page , number > ( ) ;
5454 #dialog?: Dialog ;
5555
5656 #nextSnapshotId = 1 ;
@@ -130,19 +130,27 @@ export class McpContext implements Context {
130130 }
131131
132132 setNetworkConditions ( conditions : string | null ) : void {
133- this . #networkConditions = conditions ;
133+ const page = this . getSelectedPage ( ) ;
134+ if ( conditions === null ) {
135+ this . #networkConditionsMap. delete ( page ) ;
136+ } else {
137+ this . #networkConditionsMap. set ( page , conditions ) ;
138+ }
134139 }
135140
136141 getNetworkConditions ( ) : string | null {
137- return this . #networkConditions;
142+ const page = this . getSelectedPage ( ) ;
143+ return this . #networkConditionsMap. get ( page ) ?? null ;
138144 }
139145
140146 setCpuThrottlingRate ( rate : number ) : void {
141- this . #cpuThrottlingRate = rate ;
147+ const page = this . getSelectedPage ( ) ;
148+ this . #cpuThrottlingRateMap. set ( page , rate ) ;
142149 }
143150
144151 getCpuThrottlingRate ( ) : number {
145- return this . #cpuThrottlingRate;
152+ const page = this . getSelectedPage ( ) ;
153+ return this . #cpuThrottlingRateMap. get ( page ) ?? 1 ;
146154 }
147155
148156 setIsRunningPerformanceTrace ( x : boolean ) : void {
0 commit comments