Bug 1303510 - Part 2: Add browser test for doorhanger part, r=MattN
☠☠ backed out by 5eeca8c89ac2 ☠ ☠
authorsteveck-chung <schung@mozilla.com>
Thu, 25 May 2017 11:12:52 +0800
changeset 413662 0d885ad1419d65e06e4e30e3c1ebe9acb5d288ab
parent 413661 df527bcc28dc918dc87914c9840cbde63bfdb7e0
child 413663 19bc874709946cf841baf782452939711a300102
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1303510
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1303510 - Part 2: Add browser test for doorhanger part, r=MattN MozReview-Commit-ID: LKFuW3e5scm
browser/extensions/formautofill/test/browser/browser.ini
browser/extensions/formautofill/test/browser/browser_first_time_use_doorhanger.js
--- a/browser/extensions/formautofill/test/browser/browser.ini
+++ b/browser/extensions/formautofill/test/browser/browser.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 head = head.js
 
 support-files =
   ../fixtures/autocomplete_basic.html
 
 [browser_check_installed.js]
 [browser_editProfileDialog.js]
+[browser_first_time_use_doorhanger.js]
 [browser_privacyPreferences.js]
 [browser_manageProfilesDialog.js]
 [browser_submission_in_private_mode.js]
new file mode 100644
--- /dev/null
+++ b/browser/extensions/formautofill/test/browser/browser_first_time_use_doorhanger.js
@@ -0,0 +1,79 @@
+"use strict";
+
+const FORM_URL = "http://mochi.test:8888/browser/browser/extensions/formautofill/test/browser/autocomplete_basic.html";
+const FTU_PREF = "extensions.formautofill.firstTimeUse";
+const ENABLED_PREF = "extensions.formautofill.addresses.enabled";
+
+registerCleanupFunction(async function() {
+  let addresses = await getAddresses();
+  if (addresses.length) {
+    await removeAddresses(addresses.map(address => address.guid));
+  }
+});
+
+add_task(async function test_first_time_save() {
+  let addresses = await getAddresses();
+  is(addresses.length, 0, "No profile in storage");
+  await SpecialPowers.pushPrefEnv({
+    "set": [
+      [FTU_PREF, true],
+      [ENABLED_PREF, true],
+    ],
+  });
+
+  await BrowserTestUtils.withNewTab({gBrowser, url: FORM_URL},
+    async function(browser) {
+      let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel,
+                                                       "popupshown");
+      let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:preferences#privacy");
+      await ContentTask.spawn(browser, null, async function() {
+        content.document.getElementById("organization").focus();
+        content.document.getElementById("organization").value = "Sesame Street";
+        content.document.getElementById("street-address").value = "123 Sesame Street";
+        content.document.getElementById("tel").value = "1-345-345-3456";
+
+        content.document.querySelector("input[type=submit]").click();
+      });
+
+      await promiseShown;
+      let notificationElement = PopupNotifications.panel.firstChild;
+      // Open the panel via link
+      let link = notificationElement.querySelector("popupnotificationcontent label");
+      link.click();
+      let tab = await tabPromise;
+      ok(tab, "Privacy panel opened");
+      await BrowserTestUtils.removeTab(tab);
+    }
+  );
+
+  addresses = await getAddresses();
+  is(addresses.length, 1, "Profile saved");
+  let ftuPref = SpecialPowers.getBoolPref(FTU_PREF);
+  is(ftuPref, false, "First time use flag is false");
+});
+
+add_task(async function test_non_first_time_save() {
+  let addresses = await getAddresses();
+  let ftuPref = SpecialPowers.getBoolPref(FTU_PREF);
+  is(ftuPref, false, "First time use flag is false");
+  is(addresses.length, 1, "1 address in storage");
+
+  await BrowserTestUtils.withNewTab({gBrowser, url: FORM_URL},
+    async function(browser) {
+      await ContentTask.spawn(browser, null, async function() {
+        content.document.getElementById("organization").focus();
+        content.document.getElementById("organization").value = "Mozilla";
+        content.document.getElementById("street-address").value = "331 E. Evelyn Avenue";
+        content.document.getElementById("tel").value = "1-650-903-0800";
+
+        content.document.querySelector("input[type=submit]").click();
+      });
+
+      await new Promise(resolve => setTimeout(resolve, 1000));
+      is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden");
+    }
+  );
+
+  addresses = await getAddresses();
+  is(addresses.length, 2, "Another address saved");
+});