Bug 1357026 - Open about:accounts with pre-filled email account from UITour. r=Gijs,MattN

MozReview-Commit-ID: JWFuEufGRYB

--HG--
extra : rebase_source : bf030da006a89269e6bca246a0d24fa0f3d6458b
This commit is contained in:
Rex Lee 2017-06-16 15:20:34 +08:00
parent a8908675de
commit 8054139b8e
3 changed files with 22 additions and 1 deletions

View File

@ -556,6 +556,8 @@ if (typeof Mozilla == "undefined") {
* is a string, begins with "utm_" and contains only only alphanumeric
* characters, dashes or underscores. The values may be any string and will
* automatically be encoded.
* @param {String} email - A string containing the default email account
* for the URL opened by the browser.
* @since 31, 47 for `extraURLCampaignParams`
* @example
* // Will open about:accounts?action=signup&entrypoint=uitour
@ -567,10 +569,15 @@ if (typeof Mozilla == "undefined") {
* 'utm_foo': 'bar',
* 'utm_bar': 'baz'
* });
* @example
* // Will open:
* // about:accounts?action=signup&entrypoint=uitour&email=foo%40bar.com
* Mozilla.UITour.showFirefoxAccounts(null, "foo@bar.com");
*/
Mozilla.UITour.showFirefoxAccounts = function(extraURLCampaignParams) {
Mozilla.UITour.showFirefoxAccounts = function(extraURLCampaignParams, email) {
_sendEvent("showFirefoxAccounts", {
extraURLCampaignParams: JSON.stringify(extraURLCampaignParams),
email
});
};

View File

@ -576,6 +576,9 @@ this.UITour = {
return false;
}
if (data.email) {
p.append("email", data.email);
}
// We want to replace the current tab.
browser.loadURI("about:accounts?" + p.toString());
break;

View File

@ -51,17 +51,27 @@ add_UITour_task(async function test_checkSyncCounts() {
// The showFirefoxAccounts API is sync related, so we test that here too...
add_UITour_task(async function test_firefoxAccountsNoParams() {
info("Load about:accounts containing an iframe to https://accounts.firefox.com");
await gContentAPI.showFirefoxAccounts();
await BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false,
"about:accounts?action=signup&entrypoint=uitour");
});
add_UITour_task(async function test_firefoxAccountsValidParams() {
info("Load about:accounts containing an iframe to https://accounts.firefox.com");
await gContentAPI.showFirefoxAccounts({ utm_foo: "foo", utm_bar: "bar" });
await BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false,
"about:accounts?action=signup&entrypoint=uitour&utm_foo=foo&utm_bar=bar");
});
add_UITour_task(async function test_firefoxAccountsWithEmail() {
info("Load about:accounts containing an iframe to https://accounts.firefox.com");
await gContentAPI.showFirefoxAccounts(null, "foo@bar.com");
await BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false,
"about:accounts?action=signup&entrypoint=uitour&email=foo%40bar.com");
});
add_UITour_task(async 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,
@ -69,6 +79,7 @@ add_UITour_task(async function test_firefoxAccountsNonAlphaValue() {
let value = "foo& /=?:\\\xa9";
// encodeURIComponent encodes spaces to %20 but we want "+"
let expected = encodeURIComponent(value).replace(/%20/g, "+");
info("Load about:accounts containing an iframe to https://accounts.firefox.com");
await gContentAPI.showFirefoxAccounts({ utm_foo: value });
await BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false,
"about:accounts?action=signup&entrypoint=uitour&utm_foo=" + expected);