File: browser_625016.js

package info (click to toggle)
iceweasel 31.6.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,368,576 kB
  • sloc: cpp: 3,692,968; ansic: 1,797,194; python: 193,401; java: 180,622; asm: 133,557; xml: 89,288; sh: 71,748; perl: 22,087; makefile: 21,687; objc: 4,014; yacc: 1,995; pascal: 1,292; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (86 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download | duplicates (5)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(function* setup() {
  /** Test for Bug 625016 - Restore windows closed in succession to quit (non-OSX only) **/

  // We'll test this by opening a new window, waiting for the save
  // event, then closing that window. We'll observe the
  // "sessionstore-state-write-complete" notification and check that
  // the state contains no _closedWindows. We'll then add a new tab
  // and make sure that the state following that was reset and the
  // closed window is now in _closedWindows.

  requestLongerTimeout(2);

  yield forceSaveState();

  // We'll clear all closed windows to make sure our state is clean
  // forgetClosedWindow doesn't trigger a delayed save
  while (ss.getClosedWindowCount()) {
    ss.forgetClosedWindow(0);
  }
  is(ss.getClosedWindowCount(), 0, "starting with no closed windows");
});

add_task(function* new_window() {
  let newWin;
  try {
    newWin = yield promiseNewWindowLoaded();
    let tab = newWin.gBrowser.addTab("http://example.com/browser_625016.js?" + Math.random());
    yield promiseBrowserLoaded(tab.linkedBrowser);

    // Double check that we have no closed windows
    is(ss.getClosedWindowCount(), 0, "no closed windows on first save");

    yield promiseWindowClosed(newWin);
    newWin = null;

    let state = JSON.parse((yield promiseSaveFileContents()));
    is(state.windows.length, 2,
      "observe1: 2 windows in data written to disk");
    is(state._closedWindows.length, 0,
      "observe1: no closed windows in data written to disk");

    // The API still treats the closed window as closed, so ensure that window is there
    is(ss.getClosedWindowCount(), 1,
      "observe1: 1 closed window according to API");
  } finally {
    if (newWin) {
      yield promiseWindowClosed(newWin);
    }
    yield forceSaveState();
  }
});

// We'll open a tab, which should trigger another state save which would wipe
// the _shouldRestore attribute from the closed window
add_task(function* new_tab() {
  let newTab;
  try {
    newTab = gBrowser.addTab("about:mozilla");

    let state = JSON.parse((yield promiseSaveFileContents()));
    is(state.windows.length, 1,
      "observe2: 1 window in data being written to disk");
    is(state._closedWindows.length, 1,
      "observe2: 1 closed window in data being written to disk");

    // The API still treats the closed window as closed, so ensure that window is there
    is(ss.getClosedWindowCount(), 1,
      "observe2: 1 closed window according to API");
  } finally {
    gBrowser.removeTab(newTab);
  }
});


add_task(function* done() {
  // The API still represents the closed window as closed, so we can clear it
  // with the API, but just to make sure...
//  is(ss.getClosedWindowCount(), 1, "1 closed window according to API");
  while (ss.getClosedWindowCount()) {
    ss.forgetClosedWindow(0);
  }
  Services.prefs.clearUserPref("browser.sessionstore.interval");
});