Bug 1392959 - send action=email when UITour called with email option;r=rexboy draft
authorgasolin <gasolin@gmail.com>
Mon, 11 Sep 2017 09:33:16 +0800
changeset 662090 cede0a453af901774a7b7d93e1dfd1afb9bdbea3
parent 662089 a5f163da8a9be5d2e86138c57d59be69723b5457
child 730738 2b2d5205d8749e55f73ca04bf0fc3994d82813cf
push id78944
push userbmo:gasolin@mozilla.com
push dateMon, 11 Sep 2017 01:33:51 +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 "+"