1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/contentprefs/tests/unit/test_getPrefAsync.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,34 @@ 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 +var cps = new ContentPrefInstance(null); 1.8 +var uri = ContentPrefTest.getURI("http://www.example.com/"); 1.9 + 1.10 +function run_test() { 1.11 + do_test_pending(); 1.12 + 1.13 + cps.setPref(uri, "asynctest", "pie"); 1.14 + do_check_eq(cps.getPref(uri, "asynctest"), "pie"); 1.15 + 1.16 + cps.getPref(uri, "asynctest", function(aValue) { 1.17 + do_check_eq(aValue, "pie"); 1.18 + testCallbackObj(); 1.19 + }); 1.20 +} 1.21 + 1.22 +function testCallbackObj() { 1.23 + cps.getPref(uri, "asynctest", { 1.24 + onResult: function(aValue) { 1.25 + do_check_eq(aValue, "pie"); 1.26 + cps.removePref(uri, "asynctest"); 1.27 + testNoResult(); 1.28 + } 1.29 + }); 1.30 +} 1.31 + 1.32 +function testNoResult() { 1.33 + cps.getPref(uri, "asynctest", function(aValue) { 1.34 + do_check_eq(aValue, undefined); 1.35 + do_test_finished(); 1.36 + }); 1.37 +}