diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/uitour/test/browser_UITour_sync.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/uitour/test/browser_UITour_sync.js')
-rw-r--r-- | browser/components/uitour/test/browser_UITour_sync.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/browser/components/uitour/test/browser_UITour_sync.js b/browser/components/uitour/test/browser_UITour_sync.js new file mode 100644 index 000000000..14ac0c1f6 --- /dev/null +++ b/browser/components/uitour/test/browser_UITour_sync.js @@ -0,0 +1,105 @@ +"use strict"; + +var gTestTab; +var gContentAPI; +var gContentWindow; + +registerCleanupFunction(function() { + Services.prefs.clearUserPref("services.sync.username"); +}); + +add_task(setup_UITourTest); + +add_UITour_task(function* test_checkSyncSetup_disabled() { + let result = yield getConfigurationPromise("sync"); + is(result.setup, false, "Sync shouldn't be setup by default"); +}); + +add_UITour_task(function* test_checkSyncSetup_enabled() { + Services.prefs.setCharPref("services.sync.username", "uitour@tests.mozilla.org"); + let result = yield getConfigurationPromise("sync"); + is(result.setup, true, "Sync should be setup"); +}); + +add_UITour_task(function* test_checkSyncCounts() { + Services.prefs.setIntPref("services.sync.clients.devices.desktop", 4); + Services.prefs.setIntPref("services.sync.clients.devices.mobile", 5); + Services.prefs.setIntPref("services.sync.numClients", 9); + let result = yield getConfigurationPromise("sync"); + is(result.mobileDevices, 5, "mobileDevices should be set"); + is(result.desktopDevices, 4, "desktopDevices should be set"); + is(result.totalDevices, 9, "totalDevices should be set"); + + Services.prefs.clearUserPref("services.sync.clients.devices.desktop"); + result = yield getConfigurationPromise("sync"); + is(result.mobileDevices, 5, "mobileDevices should be set"); + is(result.desktopDevices, 0, "desktopDevices should be 0"); + is(result.totalDevices, 9, "totalDevices should be set"); + + Services.prefs.clearUserPref("services.sync.clients.devices.mobile"); + result = yield getConfigurationPromise("sync"); + is(result.mobileDevices, 0, "mobileDevices should be 0"); + is(result.desktopDevices, 0, "desktopDevices should be 0"); + is(result.totalDevices, 9, "totalDevices should be set"); + + Services.prefs.clearUserPref("services.sync.numClients"); + result = yield getConfigurationPromise("sync"); + is(result.mobileDevices, 0, "mobileDevices should be 0"); + is(result.desktopDevices, 0, "desktopDevices should be 0"); + is(result.totalDevices, 0, "totalDevices should be 0"); +}); + +// The showFirefoxAccounts API is sync related, so we test that here too... +add_UITour_task(function* test_firefoxAccountsNoParams() { + yield gContentAPI.showFirefoxAccounts(); + yield BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false, + "about:accounts?action=signup&entrypoint=uitour"); +}); + +add_UITour_task(function* test_firefoxAccountsValidParams() { + yield gContentAPI.showFirefoxAccounts({ utm_foo: "foo", utm_bar: "bar" }); + yield BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false, + "about:accounts?action=signup&entrypoint=uitour&utm_foo=foo&utm_bar=bar"); +}); + +add_UITour_task(function* test_firefoxAccountsNonAlphaValue() { + // All characters in the value are allowed, but they must be automatically escaped. + // (we throw a unicode character in there too - it's not auto-utf8 encoded, + // but that's ok, so long as it is escaped correctly.) + let value = "foo& /=?:\\\xa9"; + // encodeURIComponent encodes spaces to %20 but we want "+" + let expected = encodeURIComponent(value).replace(/%20/g, "+"); + yield gContentAPI.showFirefoxAccounts({ utm_foo: value }); + yield BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false, + "about:accounts?action=signup&entrypoint=uitour&utm_foo=" + expected); +}); + +// A helper to check the request was ignored due to invalid params. +function* checkAboutAccountsNotLoaded() { + try { + yield waitForConditionPromise(() => { + return gBrowser.selectedBrowser.currentURI.spec.startsWith("about:accounts"); + }, "Check if about:accounts opened"); + ok(false, "No about:accounts tab should have opened"); + } catch (ex) { + ok(true, "No about:accounts tab opened"); + } +} + +add_UITour_task(function* test_firefoxAccountsNonObject() { + // non-string should be rejected. + yield gContentAPI.showFirefoxAccounts(99); + yield checkAboutAccountsNotLoaded(); +}); + +add_UITour_task(function* test_firefoxAccountsNonUtmPrefix() { + // Any non "utm_" name should should be rejected. + yield gContentAPI.showFirefoxAccounts({ utm_foo: "foo", bar: "bar" }); + yield checkAboutAccountsNotLoaded(); +}); + +add_UITour_task(function* test_firefoxAccountsNonAlphaName() { + // Any "utm_" name which includes non-alpha chars should be rejected. + yield gContentAPI.showFirefoxAccounts({ utm_foo: "foo", "utm_bar=": "bar" }); + yield checkAboutAccountsNotLoaded(); +}); |