File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,7 +284,9 @@ export class McpContext implements Context {
284284
285285 async restoreEmulation ( page : McpPage ) {
286286 const currentSetting = page . emulationSettings ;
287- await this . emulate ( currentSetting , page . pptrPage ) ;
287+ await this . emulate ( currentSetting , page . pptrPage , {
288+ skipNetworkReset : ! currentSetting . networkConditions ,
289+ } ) ;
288290 }
289291
290292 async emulate (
@@ -297,13 +299,18 @@ export class McpContext implements Context {
297299 viewport ?: Viewport ;
298300 } ,
299301 targetPage ?: Page ,
302+ internalOptions : {
303+ skipNetworkReset ?: boolean ;
304+ } = { } ,
300305 ) : Promise < void > {
301306 const page = targetPage ?? this . getSelectedPptrPage ( ) ;
302307 const mcpPage = this . #getMcpPage( page ) ;
303308 const newSettings : EmulationSettings = { ...mcpPage . emulationSettings } ;
304309
305310 if ( ! options . networkConditions ) {
306- await page . emulateNetworkConditions ( null ) ;
311+ if ( ! internalOptions . skipNetworkReset ) {
312+ await page . emulateNetworkConditions ( null ) ;
313+ }
307314 delete newSettings . networkConditions ;
308315 } else if ( options . networkConditions === 'Offline' ) {
309316 await page . emulateNetworkConditions ( {
Original file line number Diff line number Diff line change @@ -67,6 +67,20 @@ describe('McpContext', () => {
6767 } ) ;
6868 } ) ;
6969
70+ it ( 'does not reset network during restore when no network emulation exists' , async ( ) => {
71+ await withMcpContext ( async ( _response , context ) => {
72+ const page = context . getSelectedMcpPage ( ) ;
73+ const emulateNetworkConditionsSpy = sinon . spy (
74+ page . pptrPage ,
75+ 'emulateNetworkConditions' ,
76+ ) ;
77+
78+ await context . restoreEmulation ( page ) ;
79+
80+ sinon . assert . notCalled ( emulateNetworkConditionsSpy ) ;
81+ } ) ;
82+ } ) ;
83+
7084 it ( 'should call waitForEventsAfterAction with correct multipliers' , async ( ) => {
7185 await withMcpContext ( async ( _response , context ) => {
7286 const page = await context . newPage ( ) ;
You can’t perform that action at this time.
0 commit comments