browser/components/sessionstore/test/browser_597071.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_597071.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Bug 597071 - Closed windows should only be resurrected when there is a single
     1.9 + * popup window
    1.10 + */
    1.11 +add_task(function test_close_last_nonpopup_window() {
    1.12 +  // Purge the list of closed windows.
    1.13 +  while (ss.getClosedWindowCount()) {
    1.14 +    ss.forgetClosedWindow(0);
    1.15 +  }
    1.16 +
    1.17 +  let oldState = ss.getWindowState(window);
    1.18 +
    1.19 +  let popupState = {windows: [
    1.20 +    {tabs: [{entries: []}], isPopup: true, hidden: "toolbar"}
    1.21 +  ]};
    1.22 +
    1.23 +  // Set this window to be a popup.
    1.24 +  ss.setWindowState(window, JSON.stringify(popupState), true);
    1.25 +
    1.26 +  // Open a new window with a tab.
    1.27 +  let win = yield promiseNewWindowLoaded({private: false});
    1.28 +  let tab = win.gBrowser.addTab("http://example.com/");
    1.29 +  yield promiseBrowserLoaded(tab.linkedBrowser);
    1.30 +
    1.31 +  // Make sure sessionstore sees this window.
    1.32 +  let state = JSON.parse(ss.getBrowserState());
    1.33 +  is(state.windows.length, 2, "sessionstore knows about this window");
    1.34 +
    1.35 +  // Closed the window and check the closed window count.
    1.36 +  yield promiseWindowClosed(win);
    1.37 +  is(ss.getClosedWindowCount(), 1, "correct closed window count");
    1.38 +
    1.39 +  // Cleanup.
    1.40 +  ss.setWindowState(window, oldState, true);
    1.41 +});

mercurial