import { Frame , Page } from 'playwright' ; declare const window ; export interface WindowState { type { number } memberof innerHeight : number ; type { number } memberof innerWidth : number ; type { boolean } memberof isMaximized : boolean ; type { number } memberof outerHeight : number ; type { number } memberof outerWidth : number ; screen : { availWidth : number ; availHeight : number ; } ; } export async function getWindowState ( page ) { if ( page ) { const windowStateSerialized = await page . evaluate ( ( ) : string => { const result = { innerHeight : window . innerHeight , innerWidth : window . innerWidth , outerWidth : window . outerWidth , outerHeight : window . outerHeight , screen : { availWidth : window . screen . availWidth , availHeight : window . screen . availHeight , } , isMaximized : Math . abs ( window . outerWidth - window . screen . availWidth ) < window . screen . availWidth * 0.03 && Math . abs ( window . outerHeight - window . screen . availHeight ) < 100 , } ; return JSON . stringify ( result ) ; } ) ; const windowState = JSON . parse ( windowStateSerialized ) ; return windowState ; } throw new Error ( 'Cannot get window state because no browser has been launched' ) ; }