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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:477959a190b6
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 var cps = new ContentPrefInstance(null);
5 var uri = ContentPrefTest.getURI("http://www.example.com/");
6
7 function run_test() {
8 do_test_pending();
9
10 cps.setPref(uri, "asynctest", "pie");
11 do_check_eq(cps.getPref(uri, "asynctest"), "pie");
12
13 cps.getPref(uri, "asynctest", function(aValue) {
14 do_check_eq(aValue, "pie");
15 testCallbackObj();
16 });
17 }
18
19 function testCallbackObj() {
20 cps.getPref(uri, "asynctest", {
21 onResult: function(aValue) {
22 do_check_eq(aValue, "pie");
23 cps.removePref(uri, "asynctest");
24 testNoResult();
25 }
26 });
27 }
28
29 function testNoResult() {
30 cps.getPref(uri, "asynctest", function(aValue) {
31 do_check_eq(aValue, undefined);
32 do_test_finished();
33 });
34 }

mercurial