browser/components/sessionstore/test/browser_345898.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_345898.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     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 345898 **/
    1.10 +
    1.11 +  function test(aLambda) {
    1.12 +    try {
    1.13 +      aLambda();
    1.14 +      return false;
    1.15 +    }
    1.16 +    catch (ex) {
    1.17 +      return ex.name == "NS_ERROR_ILLEGAL_VALUE";
    1.18 +    }
    1.19 +  }
    1.20 +
    1.21 +  // all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
    1.22 +  ok(test(function() ss.getWindowState({})),
    1.23 +     "Invalid window for getWindowState throws");
    1.24 +  ok(test(function() ss.setWindowState({}, "", false)),
    1.25 +     "Invalid window for setWindowState throws");
    1.26 +  ok(test(function() ss.getTabState({})),
    1.27 +     "Invalid tab for getTabState throws");
    1.28 +  ok(test(function() ss.setTabState({}, "{}")),
    1.29 +     "Invalid tab state for setTabState throws");
    1.30 +  ok(test(function() ss.setTabState({}, JSON.stringify({ entries: [] }))),
    1.31 +     "Invalid tab for setTabState throws");
    1.32 +  ok(test(function() ss.duplicateTab({}, {})),
    1.33 +     "Invalid tab for duplicateTab throws");
    1.34 +  ok(test(function() ss.duplicateTab({}, gBrowser.selectedTab)),
    1.35 +     "Invalid window for duplicateTab throws");
    1.36 +  ok(test(function() ss.getClosedTabData({})),
    1.37 +     "Invalid window for getClosedTabData throws");
    1.38 +  ok(test(function() ss.undoCloseTab({}, 0)),
    1.39 +     "Invalid window for undoCloseTab throws");
    1.40 +  ok(test(function() ss.undoCloseTab(window, -1)),
    1.41 +     "Invalid index for undoCloseTab throws");
    1.42 +  ok(test(function() ss.getWindowValue({}, "")),
    1.43 +     "Invalid window for getWindowValue throws");
    1.44 +  ok(test(function() ss.setWindowValue({}, "", "")),
    1.45 +     "Invalid window for setWindowValue throws");
    1.46 +}

mercurial