summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/newmailaccount
diff options
context:
space:
mode:
Diffstat (limited to 'comm/mail/test/browser/newmailaccount')
-rw-r--r--comm/mail/test/browser/newmailaccount/browser.ini15
-rw-r--r--comm/mail/test/browser/newmailaccount/browser_newmailaccount.js682
-rw-r--r--comm/mail/test/browser/newmailaccount/html/badSuggestFromName4
-rw-r--r--comm/mail/test/browser/newmailaccount/html/config.xml33
-rw-r--r--comm/mail/test/browser/newmailaccount/html/configCorrupt.xml25
-rw-r--r--comm/mail/test/browser/newmailaccount/html/configError.xml6
-rw-r--r--comm/mail/test/browser/newmailaccount/html/emptySuggestFromName1
-rw-r--r--comm/mail/test/browser/newmailaccount/html/providerList63
-rw-r--r--comm/mail/test/browser/newmailaccount/html/providerListBad15
-rw-r--r--comm/mail/test/browser/newmailaccount/html/providerListIncomplete41
-rw-r--r--comm/mail/test/browser/newmailaccount/html/providerListNoOtherLangs28
-rw-r--r--comm/mail/test/browser/newmailaccount/html/providerListWildcard37
-rw-r--r--comm/mail/test/browser/newmailaccount/html/registration.html25
-rw-r--r--comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html21
-rw-r--r--comm/mail/test/browser/newmailaccount/html/registrationError.html21
-rw-r--r--comm/mail/test/browser/newmailaccount/html/suggestFromName13
-rw-r--r--comm/mail/test/browser/newmailaccount/html/target.html10
17 files changed, 1040 insertions, 0 deletions
diff --git a/comm/mail/test/browser/newmailaccount/browser.ini b/comm/mail/test/browser/newmailaccount/browser.ini
new file mode 100644
index 0000000000..ae76ec3122
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/browser.ini
@@ -0,0 +1,15 @@
+[DEFAULT]
+prefs =
+ datareporting.policy.dataSubmissionPolicyBypassNotification=true
+ mail.provider.suppress_dialog_on_startup=true
+ mail.setup.loglevel=Debug
+ mail.spotlight.firstRunDone=true
+ mail.winsearch.firstRunDone=true
+ mailnews.auto_config.addons_url=about:blank
+ mailnews.auto_config_url=about:blank
+ mailnews.start_page.override_url=about:blank
+ mailnews.start_page.url=about:blank
+subsuite = thunderbird
+support-files = html/**
+
+[browser_newmailaccount.js]
diff --git a/comm/mail/test/browser/newmailaccount/browser_newmailaccount.js b/comm/mail/test/browser/newmailaccount/browser_newmailaccount.js
new file mode 100644
index 0000000000..a3fab8d4f3
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/browser_newmailaccount.js
@@ -0,0 +1,682 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Tests the new account provisioner workflow.
+ */
+
+"use strict";
+
+var { MailServices } = ChromeUtils.import(
+ "resource:///modules/MailServices.jsm"
+);
+var { gMockPromptService } = ChromeUtils.import(
+ "resource://testing-common/mozmill/PromptHelpers.jsm"
+);
+var { wait_for_content_tab_load } = ChromeUtils.import(
+ "resource://testing-common/mozmill/ContentTabHelpers.jsm"
+);
+var { mc } = ChromeUtils.import(
+ "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
+);
+var { remove_email_account } = ChromeUtils.import(
+ "resource://testing-common/mozmill/NewMailAccountHelpers.jsm"
+);
+var { openAccountProvisioner, openAccountSetup } = ChromeUtils.import(
+ "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
+);
+var { input_value } = ChromeUtils.import(
+ "resource://testing-common/mozmill/KeyboardHelpers.jsm"
+);
+let { TelemetryTestUtils } = ChromeUtils.importESModule(
+ "resource://testing-common/TelemetryTestUtils.sys.mjs"
+);
+var { click_through_appmenu, click_menus_in_sequence } = ChromeUtils.import(
+ "resource://testing-common/mozmill/WindowHelpers.jsm"
+);
+
+// RELATIVE_ROOT messes with the collector, so we have to bring the path back
+// so we get the right path for the resources.
+var url =
+ "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/";
+var kProvisionerUrl =
+ "chrome://messenger/content/newmailaccount/accountProvisioner.xhtml";
+var kProvisionerEnabledPref = "mail.provider.enabled";
+var kSuggestFromNamePref = "mail.provider.suggestFromName";
+var kProviderListPref = "mail.provider.providerList";
+var kDefaultServerPort = 4444;
+var kDefaultServerRoot = "http://localhost:" + kDefaultServerPort;
+var gDefaultEngine;
+
+Services.prefs.setCharPref(kProviderListPref, url + "providerList");
+Services.prefs.setCharPref(kSuggestFromNamePref, url + "suggestFromName");
+
+// Here's a name that we'll type in later on. It's a global const because
+// we'll be using it in several distinct modal dialog event loops.
+var NAME = "Green Llama";
+
+// Record what the original value of the mail.provider.enabled pref is so
+// that we can put it back once the tests are done.
+var gProvisionerEnabled = Services.prefs.getBoolPref(kProvisionerEnabledPref);
+var gOldAcceptLangs = Services.locale.requestedLocales;
+var gNumAccounts;
+
+add_setup(async function () {
+ requestLongerTimeout(2);
+
+ // Make sure we enable the Account Provisioner.
+ Services.prefs.setBoolPref(kProvisionerEnabledPref, true);
+ // Restrict the user's language to just en-US
+ Services.locale.requestedLocales = ["en-US"];
+});
+
+registerCleanupFunction(async function () {
+ // Put the mail.provider.enabled pref back the way it was.
+ Services.prefs.setBoolPref(kProvisionerEnabledPref, gProvisionerEnabled);
+ // And same with the user languages
+ Services.locale.requestedLocales = gOldAcceptLangs;
+
+ // Some tests that open new windows don't return focus to the main window
+ // in a way that satisfies mochitest, and the test times out.
+ Services.focus.focusedWindow = window;
+});
+
+/**
+ * Helper function that returns the number of accounts associated with the
+ * current profile.
+ */
+function nAccounts() {
+ return MailServices.accounts.accounts.length;
+}
+
+/**
+ * Helper function to wait for the load of the account providers.
+ *
+ * @param {object} tab - The opened account provisioner tab.
+ */
+async function waitForLoadedProviders(tab) {
+ let gProvisioner = await TestUtils.waitForCondition(
+ () => tab.browser.contentWindow.gAccountProvisioner
+ );
+
+ // We got the correct amount of email and domain providers.
+ await BrowserTestUtils.waitForCondition(
+ () => gProvisioner.mailProviders.length == 4,
+ "Correctly loaded 4 email providers"
+ );
+ await BrowserTestUtils.waitForCondition(
+ () => gProvisioner.domainProviders.length == 3,
+ "Correctly loaded 3 domain providers"
+ );
+}
+
+/**
+ * Test a full account creation with an email provider.
+ */
+add_task(async function test_account_creation_from_provisioner() {
+ Services.telemetry.clearScalars();
+
+ let tab = await openAccountProvisioner();
+ let tabDocument = tab.browser.contentWindow.document;
+
+ let mailInput = tabDocument.getElementById("mailName");
+ // The focus is on the email input.
+ await BrowserTestUtils.waitForCondition(
+ () => tabDocument.activeElement == mailInput,
+ "The mailForm input field has the focus"
+ );
+
+ await waitForLoadedProviders(tab);
+
+ let scalars = TelemetryTestUtils.getProcessScalars("parent");
+ Assert.equal(
+ scalars["tb.account.opened_account_provisioner"],
+ 1,
+ "Count of opened account provisioner must be correct"
+ );
+
+ // The application will prefill these fields with the account name, if present
+ // so we need to select it before typing the new name to avoid mismatch in the
+ // expected strings during testing.
+ mailInput.select();
+ // Fill the email input.
+ input_value(mc, NAME);
+ // Since we're focused inside a form, pressing "Enter" should submit it.
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ let mailResults = tabDocument.getElementById("mailResultsArea");
+
+ // Wait for the results to be loaded.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.hasChildNodes(),
+ "Mail results loaded"
+ );
+ // We should have a total of 15 addresses.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.querySelectorAll(".result-item").length == 14,
+ "All suggested emails were correctly loaded"
+ );
+
+ // The domain section should be hidden and the buttons should be updated.
+ Assert.ok(
+ tabDocument.getElementById("domainSearch").hidden &&
+ !tabDocument.getElementById("mailSearchResults").hidden &&
+ tabDocument.getElementById("cancelButton").hidden &&
+ tabDocument.getElementById("existingButton").hidden &&
+ !tabDocument.getElementById("backButton").hidden
+ );
+
+ // Go back and fill the domain input.
+ let backButton = tabDocument.getElementById("backButton");
+ backButton.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(backButton, {}, tab.browser.contentWindow);
+
+ Assert.ok(tabDocument.getElementById("mailSearchResults").hidden);
+
+ let domainName = tabDocument.getElementById("domainName");
+ domainName.focus();
+ domainName.select();
+ // Fill the domain input.
+ input_value(mc, NAME);
+ // Since we're focused inside a form, pressing "Enter" should submit it.
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ let domainResults = tabDocument.getElementById("domainResultsArea");
+ // Wait for the results to be loaded.
+ await BrowserTestUtils.waitForCondition(
+ () => domainResults.hasChildNodes(),
+ "Domain results loaded"
+ );
+ // We should have a total of 15 addresses.
+ await BrowserTestUtils.waitForCondition(
+ () => domainResults.querySelectorAll(".result-item").length == 14,
+ "All suggested emails and domains were correctly loaded"
+ );
+
+ // The domain section should be hidden and the buttons should be updated.
+ Assert.ok(
+ !tabDocument.getElementById("domainSearch").hidden &&
+ tabDocument.getElementById("mailSearchResults").hidden &&
+ tabDocument.getElementById("cancelButton").hidden &&
+ tabDocument.getElementById("existingButton").hidden &&
+ !tabDocument.getElementById("backButton").hidden
+ );
+
+ // Go back and confirm both input fields maintained their values.
+ backButton.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(backButton, {}, tab.browser.contentWindow);
+
+ Assert.ok(
+ tabDocument.getElementById("domainSearchResults").hidden &&
+ tabDocument.getElementById("mailName").value == NAME &&
+ tabDocument.getElementById("domainName").value == NAME
+ );
+
+ // Continue with the email form.
+ tabDocument.getElementById("mailName").focus();
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ // Wait for the results to be loaded.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.hasChildNodes(),
+ "Mail results loaded"
+ );
+ // We should have a total of 15 addresses.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.querySelectorAll(".result-item").length == 14,
+ "All suggested emails were correctly loaded"
+ );
+
+ // Select the first button with a price from the results list by pressing Tab
+ // twice to move the focus on the first available price button.
+ EventUtils.synthesizeKey("VK_TAB", {}, mc.window);
+ EventUtils.synthesizeKey("VK_TAB", {}, mc.window);
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ tabDocument.activeElement ==
+ mailResults.querySelector(".result-item > button"),
+ "The first result button was focused"
+ );
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ // A special tab with the provisioner's API url should be loaded.
+ wait_for_content_tab_load(undefined, function (aURL) {
+ return aURL.schemeIs("http") && aURL.host == "mochi.test";
+ });
+
+ scalars = TelemetryTestUtils.getProcessScalars("parent", true);
+ Assert.equal(
+ scalars["tb.account.selected_account_from_provisioner"]["mochi.test"],
+ 1,
+ "Count of selected email addresses from provisioner must be correct"
+ );
+
+ // Close the account provisioner tab, and then restore it.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+ mc.window.document.getElementById("tabmail").undoCloseTab();
+ // Wait for the page to be loaded again...
+ wait_for_content_tab_load(undefined, function (aURL) {
+ return aURL.schemeIs("http") && aURL.host == "mochi.test";
+ });
+ tab = mc.window.document.getElementById("tabmail").currentTabInfo;
+
+ // Record how many accounts we start with.
+ gNumAccounts = MailServices.accounts.accounts.length;
+
+ // Simulate the purchase of an email account.
+ BrowserTestUtils.synthesizeMouseAtCenter(
+ "input[value=Send]",
+ {},
+ tab.browser
+ );
+
+ // The account setup tab should be open and selected.
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec == "about:accountsetup",
+ "The Account Setup Tab was opened"
+ );
+ // A new account should have been created.
+ Assert.equal(
+ gNumAccounts + 1,
+ MailServices.accounts.accounts.length,
+ "New account successfully created"
+ );
+
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.contentWindow.gAccountSetup?._currentModename == "success",
+ "The success view was shown"
+ );
+
+ scalars = TelemetryTestUtils.getProcessScalars("parent", true);
+ Assert.equal(
+ scalars["tb.account.new_account_from_provisioner"]["mochi.test"],
+ 1,
+ "Count of created accounts from provisioner must be correct"
+ );
+
+ // Clean it up.
+ remove_email_account("green@example.com");
+ // Close the account setup tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+});
+
+/**
+ * Test the opening and closing workflow between account setup and provisioner.
+ */
+add_task(async function test_switch_between_account_provisioner_and_setup() {
+ let tab = await openAccountProvisioner();
+ let tabDocument = tab.browser.contentWindow.document;
+
+ await waitForLoadedProviders(tab);
+
+ // Close the tab.
+ let closeButton = tabDocument.getElementById("cancelButton");
+ closeButton.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(
+ closeButton,
+ {},
+ tab.browser.contentWindow
+ );
+
+ // The account setup tab should NOT be opened.
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec != "about:accountsetup",
+ "The Account Setup Tab was not opened"
+ );
+
+ tab = await openAccountProvisioner();
+ tabDocument = tab.browser.contentWindow.document;
+
+ await waitForLoadedProviders(
+ mc.window.document.getElementById("tabmail").currentTabInfo
+ );
+
+ // Click on the "Use existing account" button.
+ let existingAccountButton = tabDocument.getElementById("existingButton");
+ existingAccountButton.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(
+ existingAccountButton,
+ {},
+ tab.browser.contentWindow
+ );
+
+ // The account setup tab should be open and selected.
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec == "about:accountsetup",
+ "The Account Setup Tab was opened"
+ );
+
+ // Close the account setup tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+});
+
+/**
+ * Test opening the account provisioner from the menu bar.
+ */
+add_task(async function open_provisioner_from_menu_bar() {
+ // Show menubar so we can click it.
+ document.getElementById("toolbar-menubar").removeAttribute("autohide");
+
+ EventUtils.synthesizeMouseAtCenter(
+ mc.window.document.getElementById("menu_File"),
+ {},
+ mc.window
+ );
+ await click_menus_in_sequence(
+ mc.window.document.getElementById("menu_FilePopup"),
+ [{ id: "menu_New" }, { id: "newCreateEmailAccountMenuItem" }]
+ );
+
+ // The account Provisioner tab should be open and selected.
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec == "about:accountprovisioner",
+ "The Account Provisioner Tab was opened"
+ );
+ await waitForLoadedProviders(
+ mc.window.document.getElementById("tabmail").currentTabInfo
+ );
+
+ // Close the account provisioner tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+}).__skipMe = AppConstants.platform == "macosx"; // Can't click menu bar on Mac.
+
+/**
+ * Test opening the account provisioner from the main app menu.
+ */
+add_task(async function open_provisioner_from_app_menu() {
+ EventUtils.synthesizeMouseAtCenter(
+ mc.window.document.getElementById("button-appmenu"),
+ {},
+ mc.window
+ );
+ click_through_appmenu(
+ [{ id: "appmenu_new" }],
+ {
+ id: "appmenu_newCreateEmailAccountMenuItem",
+ },
+ mc.window
+ );
+
+ // The account Provisioner tab should be open and selected.
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec == "about:accountprovisioner",
+ "The Account Provisioner Tab was opened"
+ );
+ await waitForLoadedProviders(
+ mc.window.document.getElementById("tabmail").currentTabInfo
+ );
+
+ // Close the account provisioner tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+}).skip();
+
+/**
+ * Test that names with HTML characters are escaped properly when displayed back
+ * to the user.
+ */
+add_task(async function test_html_characters_and_ampersands() {
+ let tab = await openAccountProvisioner();
+ let tabDocument = tab.browser.contentWindow.document;
+
+ await waitForLoadedProviders(tab);
+
+ // Type a name with some HTML tags and an ampersand in there to see if we can
+ // trip up account provisioner.
+ const CLEVER_STRING =
+ "<i>Hey, I'm ''clever &\"\" smart!<!-- Ain't I a stinkah? --></i>";
+
+ // Fill the email input.
+ input_value(mc, CLEVER_STRING);
+ // Since we're focused inside a form, pressing "Enter" should submit it.
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ let mailResults = tabDocument.getElementById("mailResultsArea");
+
+ // Wait for the results to be loaded.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.hasChildNodes(),
+ "Mail results loaded"
+ );
+
+ let searchedTerms =
+ tabDocument.getElementById("mailResultsTitle").textContent;
+ Assert.notEqual(
+ `One available address found for: "${CLEVER_STRING}"`,
+ searchedTerms
+ );
+
+ // & should have been replaced with &amp;, and the greater than / less than
+ // characters with &gt; and &lt; respectively.
+ Assert.ok(
+ searchedTerms.includes("&amp;"),
+ "Should have eliminated ampersands"
+ );
+ Assert.ok(
+ searchedTerms.includes("&gt;"),
+ "Should have eliminated greater-than signs"
+ );
+ Assert.ok(
+ searchedTerms.includes("&lt;"),
+ "Should have eliminated less-than signs"
+ );
+
+ // Close the account provisioner tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+});
+
+/**
+ * Test that if the search goes bad on the server-side we show an error.
+ */
+add_task(async function test_shows_error_on_bad_suggest_from_name() {
+ let original = Services.prefs.getCharPref(kSuggestFromNamePref);
+ Services.prefs.setCharPref(kSuggestFromNamePref, url + "badSuggestFromName");
+
+ let tab = await openAccountProvisioner();
+
+ await waitForLoadedProviders(tab);
+
+ let notificationBox =
+ tab.browser.contentWindow.gAccountProvisioner.notificationBox;
+
+ let notificationShowed = BrowserTestUtils.waitForCondition(
+ () =>
+ notificationBox.getNotificationWithValue("accountProvisionerError") !=
+ null,
+ "Timeout waiting for error notification to be showed"
+ );
+
+ // Fill the email input.
+ input_value(mc, "Boston Low");
+ // Since we're focused inside a form, pressing "Enter" should submit it.
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ // Wait for the error notification.
+ await notificationShowed;
+
+ // Close the account provisioner tab.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+ Services.prefs.setCharPref(kSuggestFromNamePref, original);
+});
+
+/**
+ * Tests that if a provider returns broken or erroneous XML back to the user
+ * after account registration, we show an alert dialog.
+ */
+add_task(async function test_error_on_corrupt_XML() {
+ // Register the prompt service to handle the alert() dialog.
+ gMockPromptService.register();
+
+ let tab = await openAccountProvisioner();
+ let tabDocument = tab.browser.contentWindow.document;
+
+ // Record how many accounts we start with.
+ gNumAccounts = nAccounts();
+
+ await waitForLoadedProviders(tab);
+
+ // Fill the email input.
+ input_value(mc, "corrupt@corrupt.invalid");
+ // Since we're focused inside a form, pressing "Enter" should submit it.
+ EventUtils.synthesizeKey("VK_RETURN", {}, mc.window);
+
+ let mailResults = tabDocument.getElementById("mailResultsArea");
+
+ // Wait for the results to be loaded.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.hasChildNodes(),
+ "Mail results loaded"
+ );
+ // We should have a total of 15 addresses.
+ await BrowserTestUtils.waitForCondition(
+ () => mailResults.querySelectorAll(".result-item").length == 14,
+ "All suggested emails were correctly loaded"
+ );
+
+ let priceButton = tabDocument.querySelector(
+ `.result-item[data-label="corrupt@corrupt.invalid"] .result-price`
+ );
+ priceButton.scrollIntoView();
+
+ EventUtils.synthesizeMouseAtCenter(
+ priceButton,
+ {},
+ tab.browser.contentWindow
+ );
+
+ // A special tab with the provisioner's API url should be loaded.
+ wait_for_content_tab_load(undefined, function (aURL) {
+ return aURL.schemeIs("http") && aURL.host == "mochi.test";
+ });
+ tab = mc.window.document.getElementById("tabmail").currentTabInfo;
+
+ gMockPromptService.returnValue = true;
+
+ // Simulate the purchase of an email account.
+ BrowserTestUtils.synthesizeMouseAtCenter(
+ "input[value=Send]",
+ {},
+ tab.browser
+ );
+ await BrowserTestUtils.waitForCondition(
+ () =>
+ mc.window.document.getElementById("tabmail").selectedTab.browser
+ ?.currentURI?.spec == "about:accountprovisioner",
+ "The Account Provisioner Tab was opened"
+ );
+
+ let promptState = gMockPromptService.promptState;
+ Assert.equal("alert", promptState.method, "An alert was showed");
+
+ Assert.equal(gNumAccounts, nAccounts(), "No new accounts have been created");
+
+ // Clean up
+ gMockPromptService.unregister();
+
+ // Close the account setup tab.
+ mc.window.document.getElementById("tabmail").closeTab(tab);
+ mc.window.document
+ .getElementById("tabmail")
+ .closeTab(mc.window.document.getElementById("tabmail").currentTabInfo);
+});
+
+/**
+ * Tests that when we pref off the Account Provisioner, the menuitem for it
+ * becomes hidden, and the button to switch to it from the Existing Account
+ * wizard also becomes hidden. Note that this doesn't test explicitly
+ * whether or not the Account Provisioner spawns when there are no accounts.
+ * The tests in this file will fail if the Account Provisioner does not spawn
+ * with no accounts, and when preffed off, if the Account Provisioner does
+ * spawn (which it shouldn't), the instrumentation Mozmill test should fail.
+ */
+add_task(async function test_can_pref_off_account_provisioner() {
+ // First, we'll disable the account provisioner.
+ Services.prefs.setBoolPref("mail.provider.enabled", false);
+
+ // Show menubar so we can click it.
+ document.getElementById("toolbar-menubar").removeAttribute("autohide");
+
+ EventUtils.synthesizeMouseAtCenter(
+ mc.window.document.getElementById("menu_File"),
+ {},
+ mc.window
+ );
+ await click_menus_in_sequence(
+ mc.window.document.getElementById("menu_FilePopup"),
+ [{ id: "menu_New" }]
+ );
+
+ // Ensure that the "Get a new mail account" menuitem is no longer available.
+ Assert.ok(
+ mc.window.document.getElementById("newCreateEmailAccountMenuItem").hidden,
+ "new account menu should be hidden"
+ );
+
+ // Close all existing tabs except the first mail tab to avoid errors.
+ mc.window.document
+ .getElementById("tabmail")
+ .closeOtherTabs(mc.window.document.getElementById("tabmail").tabInfo[0]);
+
+ // Open up the Account Hub.
+ let tab = await openAccountSetup();
+ // And make sure the Get a New Account button is hidden.
+ Assert.ok(
+ tab.browser.contentWindow.document.getElementById("provisionerButton")
+ .hidden
+ );
+ // Close the Account Hub tab.
+ mc.window.document.getElementById("tabmail").closeTab(tab);
+
+ // Ok, now pref the Account Provisioner back on
+ Services.prefs.setBoolPref("mail.provider.enabled", true);
+
+ EventUtils.synthesizeMouseAtCenter(
+ mc.window.document.getElementById("menu_File"),
+ {},
+ mc.window
+ );
+ await click_menus_in_sequence(
+ mc.window.document.getElementById("menu_FilePopup"),
+ [{ id: "menu_New" }]
+ );
+ Assert.ok(
+ !mc.window.document.getElementById("newCreateEmailAccountMenuItem").hidden,
+ "new account menu should show"
+ );
+
+ // Open up the Account Hub.
+ tab = await openAccountSetup();
+ // And make sure the Get a New Account button is hidden.
+ Assert.ok(
+ !tab.browser.contentWindow.document.getElementById("provisionerButton")
+ .hidden
+ );
+ // Close the Account Hub tab.
+ mc.window.document.getElementById("tabmail").closeTab(tab);
+}).__skipMe = AppConstants.platform == "macosx"; // Can't click menu bar on Mac.
diff --git a/comm/mail/test/browser/newmailaccount/html/badSuggestFromName b/comm/mail/test/browser/newmailaccount/html/badSuggestFromName
new file mode 100644
index 0000000000..4ff4f2769f
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/badSuggestFromName
@@ -0,0 +1,4 @@
+
+[{"product": "personalized_email", "addresses": ["green@foo.invalid",
+"green_llama@foo.invalid", "gllama@bar.cbar"}, {"product":
+, "price": "20.00", "provider": "fo"]w
diff --git a/comm/mail/test/browser/newmailaccount/html/config.xml b/comm/mail/test/browser/newmailaccount/html/config.xml
new file mode 100644
index 0000000000..f268177fb5
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/config.xml
@@ -0,0 +1,33 @@
+<clientConfig version="1.1">
+ <emailProvider id="%DOMAIN%">
+ <domain>%EMAILDOMAIN%</domain>
+ <displayName>Provisioned Account</displayName>
+ <incomingServer type="imap">
+ <hostname>imap-provisioned.%EMAILDOMAIN%</hostname>
+ <port>993</port>
+ <socketType>SSL</socketType>
+ <username>%EMAILADDRESS%</username>
+ <authentication>password-cleartext</authentication>
+ <password>Håhå</password>
+ </incomingServer>
+ <incomingServer type="pop3">
+ <hostname>pop-provisioned.%EMAILDOMAIN%</hostname>
+ <port>995</port>
+ <socketType>SSL</socketType>
+ <username>%EMAILLOCALPART%</username>
+ <authentication>password-cleartext</authentication>
+ <password>Testing</password>
+ <pop3>
+ <leaveMessagesOnServer>true</leaveMessagesOnServer>
+ </pop3>
+ </incomingServer>
+ <outgoingServer type="smtp">
+ <hostname>smtp-provisioned.%EMAILDOMAIN%</hostname>
+ <port>465</port>
+ <socketType>SSL</socketType>
+ <username>%EMAILADDRESS%</username>
+ <authentication>password-cleartext</authentication>
+ <password>Östad3</password>
+ </outgoingServer>
+ </emailProvider>
+</clientConfig>
diff --git a/comm/mail/test/browser/newmailaccount/html/configCorrupt.xml b/comm/mail/test/browser/newmailaccount/html/configCorrupt.xml
new file mode 100644
index 0000000000..edb53019bc
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/configCorrupt.xml
@@ -0,0 +1,25 @@
+<clientConfig versi">
+ <emailProvider id="%DOMAIN%">
+ <domain>%EMAILDOMAIN%</domain>
+ <displayName>Provisioned Account</displayName>
+ <displayShortName>Provisioned Account</displayShortName>
+ <incomingServer type="imap">
+ <hostname>imap.%EMAILDOMAIN%</hostname>
+ <socketType>SSL</socketType>
+ <username>%EMAILADDRESS%</username>
+ <authentication>password-cleartext</authentication>
+ </incomingServer>
+ <incomingServer type="pop3">
+ <username>%EMAILLOCALPART%</username>
+ <authentication>password-cleartext</authentication>
+ <password>Testing</password>
+ <pop3>
+ </pop3>
+ </incomingServer>
+ <outgoingServer type="smtp">
+ <hostname>smtp.%EMAILDOMAIN%</hostname>
+ <por465</port>
+ <socketType>SSL</socketType>
+ <username>%EMAILADDRESS%</username>
+ <autddhentication>password-cleartext</authentication>
+ </outgoingServer>
diff --git a/comm/mail/test/browser/newmailaccount/html/configError.xml b/comm/mail/test/browser/newmailaccount/html/configError.xml
new file mode 100644
index 0000000000..967533b666
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/configError.xml
@@ -0,0 +1,6 @@
+<clientConfig version="1.1">
+ <emailProvider id="%DOMAIN%"/>
+ <error code="USER_CANCEL">
+ You have cancelled your order.
+ </error>
+</clientConfig>
diff --git a/comm/mail/test/browser/newmailaccount/html/emptySuggestFromName b/comm/mail/test/browser/newmailaccount/html/emptySuggestFromName
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/emptySuggestFromName
@@ -0,0 +1 @@
+{}
diff --git a/comm/mail/test/browser/newmailaccount/html/providerList b/comm/mail/test/browser/newmailaccount/html/providerList
new file mode 100644
index 0000000000..9d8af7492b
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/providerList
@@ -0,0 +1,63 @@
+[{"id": "foo",
+ "label": "foo",
+ "paid": true,
+ "languages" : ["en-US"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "tos_url": "http://www.example.com/foo-tos",
+ "privacy_url": "http://www.example.com/foo-privacy",
+ "sells_domain": false
+ },
+ {"id": "bar",
+ "label": "bar",
+ "paid": false,
+ "languages" : ["en-US", "fr-FR"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/bar-tos",
+ "privacy_url": "http://www.example.com/bar-privacy",
+ "sells_domain": false
+ },
+ {"id": "French",
+ "label": "French Provider",
+ "paid": false,
+ "languages" : ["fr-FR"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/French-tos",
+ "privacy_url": "http://www.example.com/French-privacy",
+ "sells_domain": false
+ },
+ {"id": "German",
+ "label": "German Provider",
+ "paid": false,
+ "languages" : ["de-DE"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/German-tos",
+ "privacy_url": "http://www.example.com/German-privacy",
+ "sells_domain": false
+ },
+ {"id": "corrupt",
+ "label": "Corrupt Provider",
+ "paid": false,
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html",
+ "tos_url": "http://www.example.com/corrupt-tos",
+ "privacy_url": "http://www.example.com/corrupt-privacy",
+ "sells_domain": true
+ },
+ {"id": "err",
+ "label": "Error Provider",
+ "paid": false,
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registrationError.html",
+ "tos_url": "http://www.example.com/err-tos",
+ "privacy_url": "http://www.example.com/err-privacy",
+ "sells_domain": true
+ },
+ {"id": "multi",
+ "label": "multi",
+ "paid": true,
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/bar-tos",
+ "privacy_url": "http://www.example.com/bar-privacy",
+ "sells_domain": true
+ }]
diff --git a/comm/mail/test/browser/newmailaccount/html/providerListBad b/comm/mail/test/browser/newmailaccount/html/providerListBad
new file mode 100644
index 0000000000..8faf0f7cd0
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/providerListBad
@@ -0,0 +1,15 @@
+[{"id": "foo",
+ "label": "foo",
+ "paid": true,
+ "languages" : ["en-US"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "url": "http://www.example.com/api/orde"http://foo.com/tos",
+ "privacy_url": "http://foo.com/privacy",
+ "search_engine": "foo"
+ },
+: "http://example.com/",
+ "tos_url": "http://example.com/tos",
+ "privacy_url": "http://example.com/privacy"
+}
+
+]
diff --git a/comm/mail/test/browser/newmailaccount/html/providerListIncomplete b/comm/mail/test/browser/newmailaccount/html/providerListIncomplete
new file mode 100644
index 0000000000..1dfa9be2c3
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/providerListIncomplete
@@ -0,0 +1,41 @@
+[{"id": "foo",
+ "label": "foo",
+ "paid": true,
+ "languages" : ["en-US"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "tos_url": "http://www.example.com/tos",
+ "privacy_url": "http://www.example.com/privacy",
+ "search_engine": "foo"
+ },
+ {"id": "bar",
+ "label": "bar",
+ "paid": false,
+ "languages" : ["en-US", "fr-FR"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/tos",
+ "privacy_url": "http://www.example.com/privacy",
+ "search_engine": "bar"
+ },
+ {"id": "French",
+ "label": "French Provider",
+ "paid": false,
+ "languages" : ["fr-FR"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/tos",
+ "privacy_url": "http://www.example.com/privacy",
+ "search_engine": "French"
+ },
+ {"id": "German",
+ "label": "German Provider",
+ "paid": false,
+ "languages" : ["de-DE"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/tos",
+ "privacy_url": "http://www.example.com/privacy",
+ "search_engine": "German"
+},
+ {"id": "corrupt",
+ "label": "Corrupt Provider",
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html"
+}]
diff --git a/comm/mail/test/browser/newmailaccount/html/providerListNoOtherLangs b/comm/mail/test/browser/newmailaccount/html/providerListNoOtherLangs
new file mode 100644
index 0000000000..e2fa454fa0
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/providerListNoOtherLangs
@@ -0,0 +1,28 @@
+[{"id": "foo",
+ "label": "foo",
+ "paid": true,
+ "languages" : ["en-US"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "tos_url": "http://www.example.com/foo-tos",
+ "privacy_url": "http://www.example.com/foo-privacy",
+ "search_engine": "foo"
+ },
+ {"id": "bar",
+ "label": "bar",
+ "paid": false,
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/bar-tos",
+ "privacy_url": "http://www.example.com/bar-privacy",
+ "search_engine": "bar"
+ },
+ {"id": "corrupt",
+ "label": "Corrupt Provider",
+ "paid": false,
+ "languages" : ["en-US"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html",
+ "tos_url": "http://www.example.com/corrupt-tos",
+ "privacy_url": "http://www.example.com/corrupt-privacy"
+}
+
+]
diff --git a/comm/mail/test/browser/newmailaccount/html/providerListWildcard b/comm/mail/test/browser/newmailaccount/html/providerListWildcard
new file mode 100644
index 0000000000..5644013fa3
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/providerListWildcard
@@ -0,0 +1,37 @@
+[{"id": "universal",
+ "label": "Universal",
+ "paid": true,
+ "languages" : ["*"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "tos_url": "http://www.example.com/foo-tos",
+ "privacy_url": "http://www.example.com/foo-privacy",
+ "search_engine": "universal"
+ },
+{"id": "otherUniversal",
+ "label": "Other Universal",
+ "paid": true,
+ "languages" : ["*", "fr-FR"],
+ "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
+ "tos_url": "http://www.example.com/foo-tos",
+ "privacy_url": "http://www.example.com/foo-privacy",
+ "search_engine": "otherUniversal"
+ },
+ {"id": "French",
+ "label": "French Provider",
+ "paid": false,
+ "languages" : ["fr-FR"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/French-tos",
+ "privacy_url": "http://www.example.com/French-privacy",
+ "search_engine": "French"
+ },
+ {"id": "German",
+ "label": "German Provider",
+ "paid": false,
+ "languages" : ["de-DE"],
+ "api": "http://mochi.test:8888/browser/comm/mail/test/browser/newmailaccount/html/registration.html",
+ "tos_url": "http://www.example.com/German-tos",
+ "privacy_url": "http://www.example.com/German-privacy",
+ "search_engine": "German"
+ }
+]
diff --git a/comm/mail/test/browser/newmailaccount/html/registration.html b/comm/mail/test/browser/newmailaccount/html/registration.html
new file mode 100644
index 0000000000..901c16fef7
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/registration.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Fake registration page</title>
+ </head>
+ <body>
+ <div class="title">Local version</div>
+ <div class="content">
+ <form action="config.xml" method="GET">
+ <p>
+ First name: <input value="Green" id="first" name="firstname" type="text"><br>
+ Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
+ Email: <input value="da.green.llama@foo.invalid" id="email" name="email" type="text"><br>
+ <input value="Send" type="submit">
+ </p>
+ </form>
+ <a id="external" href="target.html" target="_blank">Should open externally</a>
+ <a id="internal" href="target.html">Should open internally</a>
+ <p id="newtab" onclick="window.open('target.html');">
+ Should open in a new content tab.
+ </p>
+ </div>
+ </body>
+</html>
diff --git a/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html b/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html
new file mode 100644
index 0000000000..a0a1d6d8dd
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/registrationCorrupt.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Fake registration page to Corrupt XML</title>
+ </head>
+ <body>
+
+ <div class="title">Local version</div>
+ <div class="content">
+ <form action="configCorrupt.xml" method="GET">
+ <p>
+ First name: <input value="Green" id="first" name="firstname" type="text"><br>
+ Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
+ Email: <input value="da.green.llama@example.com" id="email" name="email" type="text"><br>
+ <input value="Send" type="submit">
+ </p>
+ </form>
+ </div>
+ </body>
+</html>
diff --git a/comm/mail/test/browser/newmailaccount/html/registrationError.html b/comm/mail/test/browser/newmailaccount/html/registrationError.html
new file mode 100644
index 0000000000..9f802355d9
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/registrationError.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Fake registration page to Error XML</title>
+ </head>
+ <body>
+
+ <div class="title">Local version</div>
+ <div class="content">
+ <form action="configError.xml" method="GET">
+ <p>
+ First name: <input value="Green" id="first" name="firstname" type="text"><br>
+ Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
+ Email: <input value="da.green.llama@example.com" id="email" name="email" type="text"><br>
+ <input value="Send" type="submit">
+ </p>
+ </form>
+ </div>
+ </body>
+</html>
diff --git a/comm/mail/test/browser/newmailaccount/html/suggestFromName b/comm/mail/test/browser/newmailaccount/html/suggestFromName
new file mode 100644
index 0000000000..9e066a2a06
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/suggestFromName
@@ -0,0 +1,13 @@
+[{"product": "personalized_email", "addresses": ["green@example.com",
+"green_llama@example.com", "gllama@example.com"], "succeeded": true, "quote":
+"b28acb3c0a464d33af22", "price": 0, "provider": "bar"}, {"product":
+"personalized_email", "addresses": ["green-bar@example.com", "me-bar@example.com",
+"green-bar@madeup.invalid", "green@bar.invalid", "green@barexample.invalid",
+"greenbar@greenllama.invalid", "mebar@greenllama.invalid"], "succeeded": true, "quote":
+"3f93e48679ab46a49475", "price": "20.00", "provider": "foo"},
+{"product": "personalized_email", "addresses": ["corrupt@corrupt.invalid"],
+"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "corrupt"},
+{"product": "personalized_email", "addresses": ["error@error.invalid"],
+"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "err"},
+{"addresses": ["default@example.com", {"address": "cheap@example.com", "price": "0"},
+{"address": "expensive@example.com", "price": "$20.00"}], "succeeded": true, "price": "$20-$0", "provider": "multi"}]
diff --git a/comm/mail/test/browser/newmailaccount/html/target.html b/comm/mail/test/browser/newmailaccount/html/target.html
new file mode 100644
index 0000000000..36c0492d66
--- /dev/null
+++ b/comm/mail/test/browser/newmailaccount/html/target.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Well, how do you do!</title>
+ </head>
+ <body>
+ <h1>Testing, testing, 1..2..3..</h1>
+ </body>
+</html>