/** * Fullscreen of the game tab (#267): the button in its header puts the game view on its own into * fullscreen – no toolbar, no panels, no header –, the game keeps running, and the button in the * corner puts the view back under its header. Stopping the game from fullscreen ends it as well. */ export async function fullscreen(t) { const { check, json, click, sleep, play, stop, shot, press, exceptions } = t; const info = async () => ({ ...(await json('__gm.gameFullscreen()')), view: (await json('__gm.gameScale()')).view, }); const size = { w: await json('innerWidth'), h: await json('innerHeight') }; await press('Escape'); await play(); const windowed = await info(); // 61a. The header button: the game view alone fills the page, and the game goes on. await click(windowed.headerButton.x, windowed.headerButton.y); await sleep(500); const full = { ...(await info()), mode: await json('__gm.state.mode') }; check( 'the header button puts the running game view alone into fullscreen', windowed.view.y > 0 && full.on && full.document && full.headerButton === null && full.view.x === 0 && full.view.y === 0 && full.view.w === size.w && full.view.h === size.h && full.mode === 'play', JSON.stringify({ size, windowed, full }), ); await shot('61-fullscreen'); // 61b. The corner button leaves it, and the view is back under its header, as big as before. if (full.corner) await click(full.corner.x, full.corner.y); await sleep(500); const back = await info(); check( 'the corner button leaves fullscreen and puts the view back in its tab', full.corner !== null && !back.on && !back.document && back.headerButton !== null && JSON.stringify(back.view) === JSON.stringify(windowed.view), JSON.stringify({ corner: full.corner, back }), ); // 61c. Stop goes back to the scene tab, which ends fullscreen too. await click(back.headerButton.x, back.headerButton.y); await sleep(500); const again = await info(); await stop(); await sleep(300); const stopped = await info(); check( 'stopping the game from fullscreen ends fullscreen', again.on && !stopped.on && !stopped.document, JSON.stringify({ again: again.on, stopped }), ); check('fullscreen threw nothing', exceptions().length === 0, exceptions().join(' | ')); }