browser/components/sessionstore/test/browser_465215.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_465215.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     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 +function test() {
     1.9 +  /** Test for Bug 465215 **/
    1.10 +
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  let uniqueName = "bug 465215";
    1.14 +  let uniqueValue1 = "as good as unique: " + Date.now();
    1.15 +  let uniqueValue2 = "as good as unique: " + Math.random();
    1.16 +
    1.17 +  // set a unique value on a new, blank tab
    1.18 +  let tab1 = gBrowser.addTab();
    1.19 +  whenBrowserLoaded(tab1.linkedBrowser, function() {
    1.20 +    ss.setTabValue(tab1, uniqueName, uniqueValue1);
    1.21 +
    1.22 +    // duplicate the tab with that value
    1.23 +    let tab2 = ss.duplicateTab(window, tab1);
    1.24 +    is(ss.getTabValue(tab2, uniqueName), uniqueValue1, "tab value was duplicated");
    1.25 +
    1.26 +    ss.setTabValue(tab2, uniqueName, uniqueValue2);
    1.27 +    isnot(ss.getTabValue(tab1, uniqueName), uniqueValue2, "tab values aren't sync'd");
    1.28 +
    1.29 +    // overwrite the tab with the value which should remove it
    1.30 +    ss.setTabState(tab1, JSON.stringify({ entries: [] }));
    1.31 +    whenTabRestored(tab1, function() {
    1.32 +      is(ss.getTabValue(tab1, uniqueName), "", "tab value was cleared");
    1.33 +
    1.34 +      // clean up
    1.35 +      gBrowser.removeTab(tab2);
    1.36 +      gBrowser.removeTab(tab1);
    1.37 +      finish();
    1.38 +    });
    1.39 +  });
    1.40 +}

mercurial