browser/modules/test/unit/social/test_social.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/modules/test/unit/social/test_social.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,32 @@
     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 file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function run_test() {
     1.9 +  // we are testing worker startup specifically
    1.10 +  do_test_pending();
    1.11 +  add_test(testStartupEnabled);
    1.12 +  add_test(testDisableAfterStartup);
    1.13 +  do_initialize_social(true, run_next_test);
    1.14 +}
    1.15 +
    1.16 +function testStartupEnabled() {
    1.17 +  // wait on startup before continuing
    1.18 +  do_check_eq(Social.providers.length, 2, "two social providers enabled");
    1.19 +  do_check_true(Social.providers[0].enabled, "provider 0 is enabled");
    1.20 +  do_check_true(Social.providers[1].enabled, "provider 1 is enabled");
    1.21 +  run_next_test();
    1.22 +}
    1.23 +
    1.24 +function testDisableAfterStartup() {
    1.25 +  let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
    1.26 +  SocialService.removeProvider(Social.providers[0].origin, function() {
    1.27 +    do_wait_observer("social:providers-changed", function() {
    1.28 +      do_check_eq(Social.enabled, false, "Social is disabled");
    1.29 +      do_check_eq(Social.providers.length, 0, "no social providers available");
    1.30 +      do_test_finished();
    1.31 +      run_next_test();
    1.32 +    });
    1.33 +    SocialService.removeProvider(Social.providers[0].origin)
    1.34 +  });
    1.35 +}

mercurial