|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 "use strict"; |
|
5 |
|
6 let gTestTab; |
|
7 let gContentAPI; |
|
8 let gContentWindow; |
|
9 |
|
10 Components.utils.import("resource:///modules/UITour.jsm"); |
|
11 |
|
12 function test() { |
|
13 registerCleanupFunction(function() { |
|
14 Services.prefs.clearUserPref("services.sync.username"); |
|
15 }); |
|
16 UITourTest(); |
|
17 } |
|
18 |
|
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 } |
|
25 |
|
26 gContentAPI.getConfiguration("sync", callback); |
|
27 }, |
|
28 |
|
29 function test_checkSyncSetup_enabled(done) { |
|
30 function callback(result) { |
|
31 is(result.setup, true, "Sync should be setup"); |
|
32 done(); |
|
33 } |
|
34 |
|
35 Services.prefs.setCharPref("services.sync.username", "uitour@tests.mozilla.org"); |
|
36 gContentAPI.getConfiguration("sync", callback); |
|
37 }, |
|
38 |
|
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/"); |
|
45 |
|
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); |
|
52 |
|
53 ise(tabBrowser.contentDocument.location.href, |
|
54 "about:accounts?action=signup", |
|
55 "about:accounts should have replaced the tab"); |
|
56 |
|
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); |
|
63 |
|
64 gContentAPI.showFirefoxAccounts(); |
|
65 }); |
|
66 }, |
|
67 ]; |