Bug 758618 - Account Provisioner search button should be disabled if no providers are listed. r+ui-r=bwinton, a=Standard8.
authorMike Conley <mconley@mozilla.com>
Mon, 28 May 2012 17:05:42 -0400
changeset 11352 ff96b286f8772382b4d5ededd19b4ab2d9ed9007
parent 11351 08204ee681fe42189ae9acb5272b2874eff1817c
child 11353 0aa1e03d18936572f9d864ce5e9d3ceda43d71e6
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs758618
Bug 758618 - Account Provisioner search button should be disabled if no providers are listed. r+ui-r=bwinton, a=Standard8.
mail/components/newmailaccount/content/accountProvisioner.js
mail/test/mozmill/newmailaccount/test-newmailaccount.js
--- a/mail/components/newmailaccount/content/accountProvisioner.js
+++ b/mail/components/newmailaccount/content/accountProvisioner.js
@@ -104,16 +104,17 @@ var EmailAccountProvisioner = {
 
   _inited: false,
   _loadingProviders: false,
   _loadedProviders: false,
   _loadProviderRetryId: null,
   _storage: null,
   providers: {},
   _someProvidersChecked: false,
+  _hasSupportedLang: false,
   // These get passed in when creating the Account Provisioner window.
   NewMailAccount: window.arguments[0].NewMailAccount,
   NewComposeMessage: window.arguments[0].NewComposeMessage,
   openAddonsMgr: window.arguments[0].openAddonsMgr,
   msgWindow: window.arguments[0].msgWindow,
   okCallback: window.arguments[0].okCallback,
 
   get someProvidersChecked() {
@@ -607,16 +608,18 @@ var EmailAccountProvisioner = {
       providerCheckbox.change(function() {
         EmailAccountProvisioner.populateTermsAndPrivacyLinks();
       });
 
       if (supportsSomeUserLang) {
         providerCheckbox.attr('checked', 'checked');
         providerEntry.css('display', 'inline-block');
         providerList.append(providerEntry);
+        // Ok, at least one provider supports the user's language.
+        EmailAccountProvisioner._hasSupportedLang = true;
       }
       else {
         providerEntry.addClass("otherLanguage");
         otherLangProviders.push(providerEntry);
       }
     });
 
     for each (let [i, provider] in Iterator(otherLangProviders)) {
@@ -629,16 +632,17 @@ var EmailAccountProvisioner = {
         $("#otherLangDesc").fadeOut();
         $(".otherLanguage").fadeIn().css("display", "inline-block");
       });
     }
 
     EmailAccountProvisioner.populateTermsAndPrivacyLinks();
     EmailAccountProvisioner.beOnline();
     EmailAccountProvisioner._loadedProviders = true;
+    EmailAccountProvisioner.searchButtonEnabled(EmailAccountProvisioner._hasSupportedLang);
   },
 
   /**
    * Go through each of the checked providers, and add the appropriate
    * ToS and privacy links to the disclaimer.
    */
   populateTermsAndPrivacyLinks: function EAP_populateTOSandPrivacyLinks() {
     gLog.info("Refreshing terms and privacy links");
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -1123,8 +1123,30 @@ function subtest_disabled_fields_when_se
   server.stop(function() {
     serverStopped = true;
   });
   aController.waitFor(function() serverStopped,
                       "Timed out waiting for the fake server to stop.");
 
   close_dialog_immediately(aController);
 }
+
+function test_search_button_disabled_if_no_lang_support() {
+  // Set the user's supported language to something ridiculous (caching the
+  // old one so we can put it back later).
+  let oldLangs = Services.prefs.getCharPref(kAcceptLangs);
+  Services.prefs.setCharPref(kAcceptLangs, "foo,bar,baz");
+
+  plan_for_modal_dialog("AccountCreation",
+                        subtest_search_button_disabled_if_no_lang_support);
+  open_provisioner_window();
+  wait_for_modal_dialog("AccountCreation");
+
+  Services.prefs.setCharPref(kAcceptLangs, oldLangs);
+}
+
+function subtest_search_button_disabled_if_no_lang_support(aController) {
+  wait_for_provider_list_loaded(aController);
+
+  // The search button should be disabled.
+  wait_for_element_enabled(aController, aController.e("searchSubmit"), false);
+  close_dialog_immediately(aController);
+}