@@ -211,27 +211,17 @@ export const resizePage = defineTool({
211211 handler : async ( request , response , context ) => {
212212 const page = context . getSelectedPage ( ) ;
213213
214- const client = await page . createCDPSession ( ) ;
215- const { windowId} = await client . send ( 'Browser.getWindowForTarget' ) ;
216- const { bounds} = await client . send ( 'Browser.getWindowBounds' , {
217- windowId,
218- } ) ;
214+ const browser = page . browser ( ) ;
215+ const windowId = await page . windowId ( ) ;
216+
217+ const bounds = await browser . getWindowBounds ( windowId ) ;
219218
220219 if ( bounds . windowState === 'fullscreen' ) {
221220 // have to call this twice when window is in fullscreen mode
222- await client . send ( 'Browser.setWindowBounds' , {
223- windowId,
224- bounds : { windowState : 'normal' } ,
225- } ) ;
226- await client . send ( 'Browser.setWindowBounds' , {
227- windowId,
228- bounds : { windowState : 'normal' } ,
229- } ) ;
221+ await browser . setWindowBounds ( windowId , { windowState : 'normal' } ) ;
222+ await browser . setWindowBounds ( windowId , { windowState : 'normal' } ) ;
230223 } else if ( bounds . windowState !== 'normal' ) {
231- await client . send ( 'Browser.setWindowBounds' , {
232- windowId,
233- bounds : { windowState : 'normal' } ,
234- } ) ;
224+ await browser . setWindowBounds ( windowId , { windowState : 'normal' } ) ;
235225 }
236226 await page . resize ( {
237227 contentWidth : request . params . width ,
0 commit comments