browser/modules/test/browser_UITour_sync.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 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 "use strict";
     6 let gTestTab;
     7 let gContentAPI;
     8 let gContentWindow;
    10 Components.utils.import("resource:///modules/UITour.jsm");
    12 function test() {
    13   registerCleanupFunction(function() {
    14     Services.prefs.clearUserPref("services.sync.username");
    15   });
    16   UITourTest();
    17 }
    19 let tests = [
    20   function test_checkSyncSetup_disabled(done) {
    21     function callback(result) {
    22       is(result.setup, false, "Sync shouldn't be setup by default");
    23       done();
    24     }
    26     gContentAPI.getConfiguration("sync", callback);
    27   },
    29   function test_checkSyncSetup_enabled(done) {
    30     function callback(result) {
    31       is(result.setup, true, "Sync should be setup");
    32       done();
    33     }
    35     Services.prefs.setCharPref("services.sync.username", "uitour@tests.mozilla.org");
    36     gContentAPI.getConfiguration("sync", callback);
    37   },
    39   // The showFirefoxAccounts API is sync related, so we test that here too...
    40   function test_firefoxAccounts(done) {
    41     // This test will load about:accounts, and we don't want that to hit the
    42     // network.
    43     Services.prefs.setCharPref("identity.fxaccounts.remote.signup.uri",
    44                                "https://example.com/");
    46     loadUITourTestPage(function(contentWindow) {
    47       let tabBrowser = gBrowser.selectedTab.linkedBrowser;
    48       // This command will replace the current tab - so add a load event
    49       // handler which will fire when that happens.
    50       tabBrowser.addEventListener("load", function onload(evt) {
    51         tabBrowser.removeEventListener("load", onload, true);
    53         ise(tabBrowser.contentDocument.location.href,
    54             "about:accounts?action=signup",
    55             "about:accounts should have replaced the tab");
    57         // the iframe in about:accounts will still be loading, so we stop
    58         // that before resetting the pref.
    59         tabBrowser.contentDocument.location.href = "about:blank";
    60         Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri");
    61         done();
    62       }, true);
    64       gContentAPI.showFirefoxAccounts();
    65     });
    66   },
    67 ];

mercurial