1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/modules/test/browser_UITour_sync.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +let gTestTab; 1.10 +let gContentAPI; 1.11 +let gContentWindow; 1.12 + 1.13 +Components.utils.import("resource:///modules/UITour.jsm"); 1.14 + 1.15 +function test() { 1.16 + registerCleanupFunction(function() { 1.17 + Services.prefs.clearUserPref("services.sync.username"); 1.18 + }); 1.19 + UITourTest(); 1.20 +} 1.21 + 1.22 +let tests = [ 1.23 + function test_checkSyncSetup_disabled(done) { 1.24 + function callback(result) { 1.25 + is(result.setup, false, "Sync shouldn't be setup by default"); 1.26 + done(); 1.27 + } 1.28 + 1.29 + gContentAPI.getConfiguration("sync", callback); 1.30 + }, 1.31 + 1.32 + function test_checkSyncSetup_enabled(done) { 1.33 + function callback(result) { 1.34 + is(result.setup, true, "Sync should be setup"); 1.35 + done(); 1.36 + } 1.37 + 1.38 + Services.prefs.setCharPref("services.sync.username", "uitour@tests.mozilla.org"); 1.39 + gContentAPI.getConfiguration("sync", callback); 1.40 + }, 1.41 + 1.42 + // The showFirefoxAccounts API is sync related, so we test that here too... 1.43 + function test_firefoxAccounts(done) { 1.44 + // This test will load about:accounts, and we don't want that to hit the 1.45 + // network. 1.46 + Services.prefs.setCharPref("identity.fxaccounts.remote.signup.uri", 1.47 + "https://example.com/"); 1.48 + 1.49 + loadUITourTestPage(function(contentWindow) { 1.50 + let tabBrowser = gBrowser.selectedTab.linkedBrowser; 1.51 + // This command will replace the current tab - so add a load event 1.52 + // handler which will fire when that happens. 1.53 + tabBrowser.addEventListener("load", function onload(evt) { 1.54 + tabBrowser.removeEventListener("load", onload, true); 1.55 + 1.56 + ise(tabBrowser.contentDocument.location.href, 1.57 + "about:accounts?action=signup", 1.58 + "about:accounts should have replaced the tab"); 1.59 + 1.60 + // the iframe in about:accounts will still be loading, so we stop 1.61 + // that before resetting the pref. 1.62 + tabBrowser.contentDocument.location.href = "about:blank"; 1.63 + Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri"); 1.64 + done(); 1.65 + }, true); 1.66 + 1.67 + gContentAPI.showFirefoxAccounts(); 1.68 + }); 1.69 + }, 1.70 +];