|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function run_test() { |
|
6 var cps = new ContentPrefInstance(null); |
|
7 |
|
8 var uri = ContentPrefTest.getURI("http://www.example.com/"); |
|
9 |
|
10 do_check_thrown(function () { cps.setPref(uri, null, 8); }); |
|
11 do_check_thrown(function () { cps.hasPref(uri, null); }); |
|
12 do_check_thrown(function () { cps.getPref(uri, null); }); |
|
13 do_check_thrown(function () { cps.removePref(uri, null); }); |
|
14 do_check_thrown(function () { cps.getPrefsByName(null); }); |
|
15 do_check_thrown(function () { cps.removePrefsByName(null); }); |
|
16 |
|
17 do_check_thrown(function () { cps.setPref(uri, "", 21); }); |
|
18 do_check_thrown(function () { cps.hasPref(uri, ""); }); |
|
19 do_check_thrown(function () { cps.getPref(uri, ""); }); |
|
20 do_check_thrown(function () { cps.removePref(uri, ""); }); |
|
21 do_check_thrown(function () { cps.getPrefsByName(""); }); |
|
22 do_check_thrown(function () { cps.removePrefsByName(""); }); |
|
23 } |
|
24 |
|
25 function do_check_thrown (aCallback) { |
|
26 var exThrown = false; |
|
27 try { |
|
28 aCallback(); |
|
29 do_throw("NS_ERROR_ILLEGAL_VALUE should have been thrown here"); |
|
30 } catch (e) { |
|
31 do_check_eq(e.result, Cr.NS_ERROR_ILLEGAL_VALUE); |
|
32 exThrown = true; |
|
33 } |
|
34 do_check_true(exThrown); |
|
35 } |