forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 384278 - Added additional state variable to store window state be…
…fore window minimization. r=mikedeboer Current window state in the sessionstore system includes `sizeMode` which can be "normal", "minimized", "maximized". However, the OS also remembers whether the window was "normal" or "maximized" before minimization to restore it appropriately. With this fix, sessionstore does likewise. Differential Revision: https://phabricator.services.mozilla.com/D13234
- Loading branch information
1 parent
56e3ab9
commit 7a2d699
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
add_task(async function test() { | ||
// Test for bugfix 384278. Confirms that sizemodeBeforeMinimized is set properly when window state is saved. | ||
let win = await BrowserTestUtils.openNewBrowserWindow(); | ||
|
||
async function changeSizeMode(mode) { | ||
let promise = BrowserTestUtils.waitForEvent(win, "sizemodechange"); | ||
win[mode](); | ||
await promise; | ||
} | ||
|
||
function checkCurrentState(sizemodeBeforeMinimized) { | ||
let state = JSON.parse(ss.getWindowState(win)); | ||
let winState = state.windows[0]; | ||
is(winState.sizemodeBeforeMinimized, sizemodeBeforeMinimized, "sizemodeBeforeMinimized should match"); | ||
} | ||
|
||
// Note: Uses ss.getWindowState(win); as a more time efficient alternative to forceSaveState(); (causing timeouts). | ||
// Simulates FF restart. | ||
|
||
if (win.windowState != win.STATE_NORMAL) { | ||
await changeSizeMode("restore"); | ||
} | ||
ss.getWindowState(win); | ||
await changeSizeMode("minimize"); | ||
checkCurrentState("normal"); | ||
|
||
// Need to create new window or test will timeout on linux. | ||
await BrowserTestUtils.closeWindow(win); | ||
win = await BrowserTestUtils.openNewBrowserWindow(); | ||
|
||
if (win.windowState != win.STATE_MAXIMIZED) { | ||
await changeSizeMode("maximize"); | ||
} | ||
ss.getWindowState(win); | ||
await changeSizeMode("minimize"); | ||
checkCurrentState("maximized"); | ||
|
||
// Clean up. | ||
await BrowserTestUtils.closeWindow(win); | ||
}); |