browser_1446343-windowsize.js (1315B)
1 add_task(async function test() { 2 const win = await BrowserTestUtils.openNewBrowserWindow(); 3 4 async function changeSizeMode(mode) { 5 let promise = BrowserTestUtils.waitForEvent(win, "sizemodechange"); 6 win[mode](); 7 await promise; 8 } 9 if (win.windowState != win.STATE_NORMAL) { 10 await changeSizeMode("restore"); 11 } 12 13 const { outerWidth, outerHeight, screenX, screenY } = win; 14 function checkCurrentState(sizemode) { 15 let state = ss.getWindowState(win); 16 let winState = state.windows[0]; 17 let msgSuffix = ` should match on ${sizemode} mode`; 18 is(winState.width, outerWidth, "width" + msgSuffix); 19 is(winState.height, outerHeight, "height" + msgSuffix); 20 // The position attributes seem to be affected on macOS when the 21 // window gets maximized, so skip checking them for now. 22 if (AppConstants.platform != "macosx" || sizemode == "normal") { 23 is(winState.screenX, screenX, "screenX" + msgSuffix); 24 is(winState.screenY, screenY, "screenY" + msgSuffix); 25 } 26 is(winState.sizemode, sizemode, "sizemode should match"); 27 } 28 29 checkCurrentState("normal"); 30 31 await changeSizeMode("maximize"); 32 checkCurrentState("maximized"); 33 34 await changeSizeMode("minimize"); 35 checkCurrentState("minimized"); 36 37 // Clean up. 38 await BrowserTestUtils.closeWindow(win); 39 });