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

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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/");
     7 function run_test() {
     8   do_test_pending();
    10   cps.setPref(uri, "asynctest", "pie");
    11   do_check_eq(cps.getPref(uri, "asynctest"), "pie");
    13   cps.getPref(uri, "asynctest", function(aValue) {
    14     do_check_eq(aValue, "pie");
    15     testCallbackObj();
    16   });
    17 }
    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 }
    29 function testNoResult() {
    30   cps.getPref(uri, "asynctest", function(aValue) {
    31     do_check_eq(aValue, undefined);
    32     do_test_finished();
    33   });
    34 }

mercurial