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