summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js
blob: a832e71bcf46a843fbd7fc5e198c8f4504aabfbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 = 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);
});