Bug 1414740 - Insert info log before async helper functions in form autofill mochitests. r=lchang
authorRay Lin <ralin@mozilla.com>
Mon, 06 Nov 2017 17:58:41 +0800
changeset 443745 3b928622368e4bc99502d37c9015565e517d3bd5
parent 443744 b7c6b59f2739ea23040f030a3343c33ec1864fe3
child 443746 ea03ba856101fd7d9c3fcaf642a8e0f7c3fd115c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslchang
bugs1414740
milestone58.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 1414740 - Insert info log before async helper functions in form autofill mochitests. r=lchang MozReview-Commit-ID: JJN7R2WC2D4
browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
browser/extensions/formautofill/test/browser/browser_autocomplete_marked_back_forward.js
browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js
browser/extensions/formautofill/test/browser/browser_insecure_form.js
browser/extensions/formautofill/test/browser/head.js
browser/extensions/formautofill/test/mochitest/formautofill_common.js
browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html
browser/extensions/formautofill/test/mochitest/test_clear_form.html
browser/extensions/formautofill/test/mochitest/test_form_changes.html
browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
--- a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
+++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
@@ -23,18 +23,23 @@ add_task(async function setup_storage() 
 add_task(async function test_click_on_footer() {
   await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
     const {autoCompletePopup: {richlistbox: itemsBox}} = browser;
 
     await openPopupOn(browser, "#organization");
     // Click on the footer
     const optionButton = itemsBox.querySelector(".autocomplete-richlistitem:last-child")._optionButton;
     const prefTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, PRIVACY_PREF_URL);
+    // Wait for dropdown animation finished to continue mouse synthesizing.
+    await sleep(1000);
     await EventUtils.synthesizeMouseAtCenter(optionButton, {});
-    await BrowserTestUtils.removeTab(await prefTabPromise);
+    info(`expecting tab: about:preferences#privacy opened`);
+    const prefTab = await prefTabPromise;
+    info(`expecting tab: about:preferences#privacy removed`);
+    await BrowserTestUtils.removeTab(prefTab);
     ok(true, "Tab: preferences#privacy was successfully opened by clicking on the footer");
 
     await closePopup(browser);
   });
 });
 
 add_task(async function test_press_enter_on_footer() {
   await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
@@ -43,17 +48,20 @@ add_task(async function test_press_enter
     await openPopupOn(browser, "#organization");
     // Navigate to the footer and press enter.
     const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem");
     const prefTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, PRIVACY_PREF_URL);
     for (let i = 0; i < listItemElems.length; i++) {
       await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
     }
     await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser);
-    await BrowserTestUtils.removeTab(await prefTabPromise);
+    info(`expecting tab: about:preferences#privacy opened`);
+    const prefTab = await prefTabPromise;
+    info(`expecting tab: about:preferences#privacy removed`);
+    await BrowserTestUtils.removeTab(prefTab);
     ok(true, "Tab: preferences#privacy was successfully opened by pressing enter on the footer");
 
     await closePopup(browser);
   });
 });
 
 add_task(async function test_phishing_warning_single_category() {
   await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
--- a/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_back_forward.js
+++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_back_forward.js
@@ -26,31 +26,34 @@ add_task(async function test_back_forwar
 
     // Check the page after the initial load
     await openPopupOn(browser, "#street-address");
     checkPopup(autoCompletePopup);
 
     // Now navigate forward and make sure autofill autocomplete results are still attached
     let loadPromise = BrowserTestUtils.browserLoaded(browser);
     await BrowserTestUtils.loadURI(browser, `${URL}?load=2`);
+    info("expecting browser loaded");
     await loadPromise;
 
     // Check the second page
     await openPopupOn(browser, "#street-address");
     checkPopup(autoCompletePopup);
 
     // Check after hitting back to the first page
     let stoppedPromise = BrowserTestUtils.browserStopped(browser);
     browser.goBack();
+    info("expecting browser stopped");
     await stoppedPromise;
     await openPopupOn(browser, "#street-address");
     checkPopup(autoCompletePopup);
 
     // Check after hitting forward to the second page
     stoppedPromise = BrowserTestUtils.browserStopped(browser);
     browser.goForward();
+    info("expecting browser stopped");
     await stoppedPromise;
     await openPopupOn(browser, "#street-address");
     checkPopup(autoCompletePopup);
 
     await closePopup(browser);
   });
 });
--- a/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js
+++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js
@@ -25,16 +25,17 @@ add_task(async function test_detach_tab_
     const {autoCompletePopup} = browser;
 
     // Check the page after the initial load
     await openPopupOn(browser, "#street-address");
     checkPopup(autoCompletePopup);
     await closePopup(browser);
 
     // Detach the tab to a new window
+    info("expecting tab replaced with new window");
     let newWin = gBrowser.replaceTabWithWindow(gBrowser.getTabForBrowser(browser));
     await TestUtils.topicObserved("browser-delayed-startup-finished", subject => {
       return subject == newWin;
     });
 
     info("tab was detached");
     let newBrowser = newWin.gBrowser.selectedBrowser;
     ok(newBrowser, "Found new <browser>");
--- a/browser/extensions/formautofill/test/browser/browser_insecure_form.js
+++ b/browser/extensions/formautofill/test/browser/browser_insecure_form.js
@@ -48,20 +48,19 @@ add_task(async function test_insecure_fo
   }, {
     urlPath: TEST_URL_PATH_CC,
     protocol: "http",
     focusInput: "#cc-name",
     expectedType: "autofill-insecureWarning", // insecure warning field
     expectedResultLength: 1,
   }];
 
-  await runTest(testSets[0]);
-  await runTest(testSets[1]);
-  await runTest(testSets[2]);
-  await runTest(testSets[3]);
+  for (const test of testSets) {
+    await runTest(test);
+  }
 });
 
 add_task(async function test_click_on_insecure_warning() {
   await BrowserTestUtils.withNewTab({gBrowser, url: "http" + TEST_URL_PATH_CC}, async function(browser) {
     await openPopupOn(browser, "#cc-name");
 
     const insecureItem = getDisplayedPopupItems(browser)[0];
     await EventUtils.synthesizeMouseAtCenter(insecureItem, {});
--- a/browser/extensions/formautofill/test/browser/head.js
+++ b/browser/extensions/formautofill/test/browser/head.js
@@ -97,16 +97,17 @@ function getDisplayedPopupItems(browser,
   return [...listItemElems].filter(item => item.getAttribute("collapsed") != "true");
 }
 
 async function sleep(ms = 500) {
   await new Promise(resolve => setTimeout(resolve, ms));
 }
 
 async function focusAndWaitForFieldsIdentified(browser, selector) {
+  info("expecting the target input being focused and indentified");
   /* eslint no-shadow: ["error", { "allow": ["selector", "previouslyFocused", "previouslyIdentified"] }] */
   const {previouslyFocused, previouslyIdentified} = await ContentTask.spawn(browser, {selector}, async function({selector}) {
     Components.utils.import("resource://gre/modules/FormLikeFactory.jsm");
     const input = content.document.querySelector(selector);
     const rootElement = FormLikeFactory.findRootForField(input);
     const previouslyFocused = content.document.activeElement == input;
     const previouslyIdentified = rootElement.hasAttribute("test-formautofill-identified");
 
@@ -171,16 +172,17 @@ async function closePopup(browser) {
   await ContentTask.spawn(browser, {}, async function() {
     content.document.activeElement.blur();
   });
 
   await expectPopupClose(browser);
 }
 
 function getRecords(data) {
+  info(`expecting record retrievals: ${data.collectionName}`);
   return new Promise(resolve => {
     Services.cpmm.addMessageListener("FormAutofill:Records", function getResult(result) {
       Services.cpmm.removeMessageListener("FormAutofill:Records", getResult);
       resolve(result.data);
     });
     Services.cpmm.sendAsyncMessage("FormAutofill:GetRecords", data);
   });
 }
@@ -189,34 +191,38 @@ function getAddresses() {
   return getRecords({collectionName: "addresses"});
 }
 
 function getCreditCards() {
   return getRecords({collectionName: "creditCards"});
 }
 
 function saveAddress(address) {
+  info("expecting address saved");
   Services.cpmm.sendAsyncMessage("FormAutofill:SaveAddress", {address});
   return TestUtils.topicObserved("formautofill-storage-changed");
 }
 
 function saveCreditCard(creditcard) {
+  info("expecting credit card saved");
   let creditcardClone = Object.assign({}, creditcard);
   Services.cpmm.sendAsyncMessage("FormAutofill:SaveCreditCard", {
     creditcard: creditcardClone,
   });
   return TestUtils.topicObserved("formautofill-storage-changed");
 }
 
 function removeAddresses(guids) {
+  info("expecting address removed");
   Services.cpmm.sendAsyncMessage("FormAutofill:RemoveAddresses", {guids});
   return TestUtils.topicObserved("formautofill-storage-changed");
 }
 
 function removeCreditCards(guids) {
+  info("expecting credit card removed");
   Services.cpmm.sendAsyncMessage("FormAutofill:RemoveCreditCards", {guids});
   return TestUtils.topicObserved("formautofill-storage-changed");
 }
 
 function getNotification(index = 0) {
   let notifications = PopupNotifications.panel.childNodes;
   ok(notifications.length > 0, "at least one notification displayed");
   ok(true, notifications.length + " notification(s)");
@@ -231,44 +237,48 @@ function getNotification(index = 0) {
  */
 async function clickDoorhangerButton(button, index) {
   let popuphidden = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
 
   if (button == MAIN_BUTTON || button == SECONDARY_BUTTON) {
     EventUtils.synthesizeMouseAtCenter(getNotification()[button], {});
   } else if (button == MENU_BUTTON) {
     // Click the dropmarker arrow and wait for the menu to show up.
+    info("expecting notification menu button present");
     await BrowserTestUtils.waitForCondition(() => getNotification().menubutton);
     await sleep(2000); // menubutton needs extra time for binding
     let notification = getNotification();
     ok(notification.menubutton, "notification menupopup displayed");
     let dropdownPromise =
       BrowserTestUtils.waitForEvent(notification.menupopup, "popupshown");
     await EventUtils.synthesizeMouseAtCenter(notification.menubutton, {});
+    info("expecting notification popup show up");
     await dropdownPromise;
 
     let actionMenuItem = notification.querySelectorAll("menuitem")[index];
     await EventUtils.synthesizeMouseAtCenter(actionMenuItem, {});
   }
+  info("expecting notification popup hidden");
   await popuphidden;
 }
 
 
 function getDoorhangerCheckbox() {
   return getNotification().checkbox;
 }
 
 function getDoorhangerButton(button) {
   return getNotification()[button];
 }
 
 
 // Wait for the master password dialog to popup and enter the password to log in
 // if "login" is "true" or dismiss it directly if otherwise.
 function waitForMasterPasswordDialog(login = false) {
+  info("expecting master password dialog loaded");
   let dialogShown = TestUtils.topicObserved("common-dialog-loaded");
   return dialogShown.then(([subject]) => {
     let dialog = subject.Dialog;
     is(dialog.args.title, "Password Required", "Master password dialog shown");
     if (login) {
       dialog.ui.password1Textbox.value = LoginTestUtils.masterPassword.masterPassword;
       dialog.ui.button0.click();
     } else {
--- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js
+++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js
@@ -10,16 +10,17 @@ let expectingPopup = null;
 const {FormAutofillUtils} = SpecialPowers.Cu.import("resource://formautofill/FormAutofillUtils.jsm");
 
 async function sleep(ms = 500, reason = "Intentionally wait for UI ready") {
   SimpleTest.requestFlakyTimeout(reason);
   await new Promise(resolve => setTimeout(resolve, ms));
 }
 
 async function focusAndWaitForFieldsIdentified(input, mustBeIdentified = false) {
+  info("expecting the target input being focused and indentified");
   if (typeof input === "string") {
     input = document.querySelector(input);
   }
   const rootElement = input.form || input.ownerDocument.documentElement;
   const previouslyFocused = input != document.activeElement;
 
   input.focus();
 
@@ -61,16 +62,17 @@ function clickOnElement(selector) {
   if (!element) {
     throw new Error("Can not find the element");
   }
 
   SimpleTest.executeSoon(() => element.click());
 }
 
 async function onStorageChanged(type) {
+  info(`expecting the storage changed: ${type}`);
   return new Promise(resolve => {
     formFillChromeScript.addMessageListener("formautofill-storage-changed", function onChanged(data) {
       formFillChromeScript.removeMessageListener("formautofill-storage-changed", onChanged);
       is(data.data, type, `Receive ${type} storage changed event`);
       resolve();
     });
   });
 }
@@ -82,16 +84,17 @@ function checkMenuEntries(expectedValues
 
   is(actualValues.length, expectedLength, " Checking length of expected menu");
   for (let i = 0; i < expectedValues.length; i++) {
     is(actualValues[i], expectedValues[i], " Checking menu entry #" + i);
   }
 }
 
 function invokeAsyncChromeTask(message, response, payload = {}) {
+  info(`expecting the chrome task finished: ${message}`);
   return new Promise(resolve => {
     formFillChromeScript.sendAsyncMessage(message, payload);
     formFillChromeScript.addMessageListener(response, function onReceived(data) {
       formFillChromeScript.removeMessageListener(response, onReceived);
 
       resolve(data);
     });
   });
@@ -187,16 +190,17 @@ function formAutoFillCommonSetup() {
     gLastAutoCompleteResults = results;
     if (gPopupShownListener) {
       gPopupShownListener({results});
     }
   });
 
   SimpleTest.registerCleanupFunction(async () => {
     formFillChromeScript.sendAsyncMessage("cleanup");
+    info(`expecting the storage cleanup`);
     await formFillChromeScript.promiseOneMessage("cleanup-finished");
 
     formFillChromeScript.destroy();
     expectingPopup = null;
   });
 }
 
 formAutoFillCommonSetup();
--- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
@@ -56,16 +56,17 @@ function checkAutoCompleteInputFilled(el
     element.addEventListener("DOMAutoComplete", function onChange() {
       is(element.value, expectedvalue, "Checking " + element.name + " field");
       resolve();
     }, {once: true});
   });
 }
 
 function checkFormFilled(address) {
+  info("expecting form filled");
   let promises = [];
   for (let prop in address) {
     let element = document.getElementById(prop);
     if (document.activeElement == element) {
       promises.push(checkAutoCompleteInputFilled(element, address[prop]));
     } else {
       let converted = address[prop];
       if (prop == "street-address") {
--- a/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html
@@ -57,16 +57,17 @@ function checkElementFilled(element, exp
       }, {once: true});
     }));
   }
 
   return promises;
 }
 
 function checkFormFilled(creditCard) {
+  info("expecting form filled");
   let promises = [];
   for (let prop in creditCard) {
     let element = document.getElementById(prop);
     let converted = String(creditCard[prop]); // Convert potential number to string
 
     promises.push(...checkElementFilled(element, converted));
   }
   doKey("return");
deleted file mode 100644
--- a/browser/extensions/formautofill/test/mochitest/test_form_changes.html
+++ b/browser/extensions/formautofill/test/mochitest/test_form_changes.html
@@ -42,16 +42,17 @@ function addInputField(form, className) 
   let newElem = document.createElement("input");
   newElem.name = className;
   newElem.autocomplete = className;
   newElem.type = "text";
   form.appendChild(newElem);
 }
 
 async function checkFormChangeHappened(formId) {
+  info("expecting form changed");
   await focusAndWaitForFieldsIdentified(`#${formId} input[name=tel]`);
   doKey("down");
   await expectPopup();
   checkMenuEntries(MOCK_STORAGE.map(address =>
     JSON.stringify({primary: address.tel, secondary: address.name})
   ));
 
   // This is for checking the changes of element count.
--- a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
+++ b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
@@ -68,16 +68,17 @@ function checkFormFilledFields(address) 
   for (const input of inputs) {
     const isFilledByAutofill = !!address[input.id];
 
     checkFilledFieldHighlight(input, isFilledByAutofill);
   }
 }
 
 function confirmAllFieldsFilled(address) {
+  info("expecting form filled");
   const pendingPromises = [];
 
   for (const prop in address) {
     const element = document.getElementById(prop);
 
     pendingPromises.push(new Promise(resolve => {
       element.addEventListener("change", resolve, {once: true});
     }));