michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function run_test() { michael@0: var cps = new ContentPrefInstance(null); michael@0: michael@0: var uri = ContentPrefTest.getURI("http://www.example.com/"); michael@0: michael@0: do_check_thrown(function () { cps.setPref(uri, null, 8); }); michael@0: do_check_thrown(function () { cps.hasPref(uri, null); }); michael@0: do_check_thrown(function () { cps.getPref(uri, null); }); michael@0: do_check_thrown(function () { cps.removePref(uri, null); }); michael@0: do_check_thrown(function () { cps.getPrefsByName(null); }); michael@0: do_check_thrown(function () { cps.removePrefsByName(null); }); michael@0: michael@0: do_check_thrown(function () { cps.setPref(uri, "", 21); }); michael@0: do_check_thrown(function () { cps.hasPref(uri, ""); }); michael@0: do_check_thrown(function () { cps.getPref(uri, ""); }); michael@0: do_check_thrown(function () { cps.removePref(uri, ""); }); michael@0: do_check_thrown(function () { cps.getPrefsByName(""); }); michael@0: do_check_thrown(function () { cps.removePrefsByName(""); }); michael@0: } michael@0: michael@0: function do_check_thrown (aCallback) { michael@0: var exThrown = false; michael@0: try { michael@0: aCallback(); michael@0: do_throw("NS_ERROR_ILLEGAL_VALUE should have been thrown here"); michael@0: } catch (e) { michael@0: do_check_eq(e.result, Cr.NS_ERROR_ILLEGAL_VALUE); michael@0: exThrown = true; michael@0: } michael@0: do_check_true(exThrown); michael@0: }