browser/components/sessionstore/test/browser_624727.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_624727.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function test() {
     1.8 +  TestRunner.run();
     1.9 +}
    1.10 +
    1.11 +function runTests() {
    1.12 +  function assertNumberOfTabs(num, msg) {
    1.13 +    is(gBrowser.tabs.length, num, msg);
    1.14 +  }
    1.15 +
    1.16 +  function assertNumberOfPinnedTabs(num, msg) {
    1.17 +    is(gBrowser._numPinnedTabs, num, msg);
    1.18 +  }
    1.19 +
    1.20 +  // check prerequisites
    1.21 +  assertNumberOfTabs(1, "we start off with one tab");
    1.22 +  assertNumberOfPinnedTabs(0, "no pinned tabs so far");
    1.23 +
    1.24 +  // setup
    1.25 +  gBrowser.addTab("about:blank");
    1.26 +  assertNumberOfTabs(2, "there are two tabs, now");
    1.27 +
    1.28 +  let [tab1, tab2] = gBrowser.tabs;
    1.29 +  let linkedBrowser = tab1.linkedBrowser;
    1.30 +  gBrowser.pinTab(tab1);
    1.31 +  gBrowser.pinTab(tab2);
    1.32 +  assertNumberOfPinnedTabs(2, "both tabs are now pinned");
    1.33 +
    1.34 +  // run the test
    1.35 +  yield waitForBrowserState(
    1.36 +    { windows: [{ tabs: [{ url: "about:blank" }] }] },
    1.37 +    function () {
    1.38 +      assertNumberOfTabs(1, "one tab left after setBrowserState()");
    1.39 +      assertNumberOfPinnedTabs(0, "there are no pinned tabs");
    1.40 +      is(gBrowser.tabs[0].linkedBrowser, linkedBrowser, "first tab's browser got re-used");
    1.41 +      next();
    1.42 +    }
    1.43 +  );
    1.44 +}

mercurial