Bug 1392959 - send action=email when UITour called with email option;r=rexboy
authorgasolin <gasolin@gmail.com>
Mon, 11 Sep 2017 09:33:16 +0800
changeset 662262 fc6d97762cdb8e95a51b5fe0a620ae10ac4a5e7e
parent 662261 529bfc306853af0afdbc2471deaca2c979be8617
child 662263 5310033cd68c4f9dc06d0f62b3ff854666691255
push id79014
push userbmo:bpostelnicu@mozilla.com
push dateMon, 11 Sep 2017 09:58:20 +0000
reviewersrexboy
bugs1392959
milestone57.0a1
Bug 1392959 - send action=email when UITour called with email option;r=rexboy MozReview-Commit-ID: J08pXaJwAhh
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour_sync.js
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -558,28 +558,33 @@ this.UITour = {
           log.warn("openPreferences: Invalid pane specified");
           return false;
         }
         window.openPreferences(data.pane, { origin: "UITour" });
         break;
       }
 
       case "showFirefoxAccounts": {
-        // 'signup' is the only action that makes sense currently, so we don't
-        // accept arbitrary actions just to be safe...
-        let p = new URLSearchParams("action=signup&entrypoint=uitour");
+        let p;
+        if (data.email) {
+          // With email parameter added, we need to use 'email' action to help FxA determine
+          // whether the email is registered or not and direct the user down the correct flow
+          p =  new URLSearchParams("action=email&entrypoint=uitour");
+          p.append("email", data.email);
+        } else {
+          // 'signup' is the default action that makes sense currently, so we don't
+          // accept arbitrary actions just to be safe...
+          p =  new URLSearchParams("action=signup&entrypoint=uitour");
+        }
         // Call our helper to validate extraURLCampaignParams and populate URLSearchParams
         if (!this._populateCampaignParams(p, data.extraURLCampaignParams)) {
           log.warn("showFirefoxAccounts: invalid campaign args specified");
           return false;
         }
 
-        if (data.email) {
-          p.append("email", data.email);
-        }
         // We want to replace the current tab.
         browser.loadURI("about:accounts?" + p.toString());
         break;
       }
 
       case "resetFirefox": {
         // Open a reset profile dialog window.
         if (ResetProfile.resetSupported()) {
--- a/browser/components/uitour/test/browser_UITour_sync.js
+++ b/browser/components/uitour/test/browser_UITour_sync.js
@@ -64,17 +64,17 @@ add_UITour_task(async function test_fire
   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");
+                                       "about:accounts?action=email&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,
   // but that's ok, so long as it is escaped correctly.)
   let value = "foo& /=?:\\\xa9";
   // encodeURIComponent encodes spaces to %20 but we want "+"