diff --git a/browser/components/uitour/UITour-lib.js b/browser/components/uitour/UITour-lib.js index b225e76a876d..d49449189dec 100644 --- a/browser/components/uitour/UITour-lib.js +++ b/browser/components/uitour/UITour-lib.js @@ -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 }); }; diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index 3585d141ac6f..ffb45fd2f54b 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -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; diff --git a/browser/components/uitour/test/browser_UITour_sync.js b/browser/components/uitour/test/browser_UITour_sync.js index da8fc2c8b749..2c32c070916a 100644 --- a/browser/components/uitour/test/browser_UITour_sync.js +++ b/browser/components/uitour/test/browser_UITour_sync.js @@ -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);