browser/components/sessionstore/test/browser_586068-apptabs.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_586068-apptabs.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
     1.9 +
    1.10 +function test() {
    1.11 +  TestRunner.run();
    1.12 +}
    1.13 +
    1.14 +function runTests() {
    1.15 +  Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
    1.16 +  registerCleanupFunction(function () {
    1.17 +    Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
    1.18 +  });
    1.19 +
    1.20 +  let state = { windows: [{ tabs: [
    1.21 +    { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true },
    1.22 +    { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
    1.23 +    { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
    1.24 +    { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
    1.25 +    { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
    1.26 +    { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
    1.27 +    { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
    1.28 +  ], selected: 5 }] };
    1.29 +
    1.30 +  let loadCount = 0;
    1.31 +  gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
    1.32 +    loadCount++;
    1.33 +
    1.34 +    // We'll make sure that the loads we get come from pinned tabs or the
    1.35 +    // the selected tab.
    1.36 +
    1.37 +    // get the tab
    1.38 +    let tab;
    1.39 +    for (let i = 0; i < window.gBrowser.tabs.length; i++) {
    1.40 +      if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
    1.41 +        tab = window.gBrowser.tabs[i];
    1.42 +    }
    1.43 +
    1.44 +    ok(tab.pinned || tab.selected,
    1.45 +       "load came from pinned or selected tab");
    1.46 +
    1.47 +    // We should get 4 loads: 3 app tabs + 1 normal selected tab
    1.48 +    if (loadCount < 4)
    1.49 +      return;
    1.50 +
    1.51 +    gProgressListener.unsetCallback();
    1.52 +    executeSoon(next);
    1.53 +  });
    1.54 +
    1.55 +  yield ss.setBrowserState(JSON.stringify(state));
    1.56 +}

mercurial