toolkit/components/contentprefs/tests/unit/test_bug503971.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/contentprefs/tests/unit/test_bug503971.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     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 run_test() {
     1.9 +  var cps = new ContentPrefInstance(null);
    1.10 +
    1.11 +  var uri = ContentPrefTest.getURI("http://www.example.com/");
    1.12 +  
    1.13 +  do_check_thrown(function () { cps.setPref(uri, null, 8); });
    1.14 +  do_check_thrown(function () { cps.hasPref(uri, null); });
    1.15 +  do_check_thrown(function () { cps.getPref(uri, null); });
    1.16 +  do_check_thrown(function () { cps.removePref(uri, null); });
    1.17 +  do_check_thrown(function () { cps.getPrefsByName(null); });
    1.18 +  do_check_thrown(function () { cps.removePrefsByName(null); });
    1.19 +
    1.20 +  do_check_thrown(function () { cps.setPref(uri, "", 21); });
    1.21 +  do_check_thrown(function () { cps.hasPref(uri, ""); });
    1.22 +  do_check_thrown(function () { cps.getPref(uri, ""); });
    1.23 +  do_check_thrown(function () { cps.removePref(uri, ""); });
    1.24 +  do_check_thrown(function () { cps.getPrefsByName(""); });
    1.25 +  do_check_thrown(function () { cps.removePrefsByName(""); });
    1.26 +}
    1.27 +
    1.28 +function do_check_thrown (aCallback) {
    1.29 +  var exThrown = false;
    1.30 +  try {
    1.31 +    aCallback();
    1.32 +    do_throw("NS_ERROR_ILLEGAL_VALUE should have been thrown here");
    1.33 +  } catch (e) {
    1.34 +    do_check_eq(e.result, Cr.NS_ERROR_ILLEGAL_VALUE);
    1.35 +    exThrown = true;
    1.36 +  }
    1.37 +  do_check_true(exThrown);
    1.38 +}

mercurial