Bug 1337772 - Fix intermittent browser_context_menu_autocomplete_interaction.js. r=MattN
authorJohann Hofmann <jhofmann@mozilla.com>
Wed, 01 Mar 2017 20:05:38 +0100
changeset 394833 ebf65a1af072e0c4d258257477812dc66c8b635d
parent 394832 5d85f0b3dea8ed56b17cd8dca3a231ea055e19d2
child 394834 0fc0b762b40a72ffdb519167dd5b249a3ea629b2
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1337772
milestone54.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 1337772 - Fix intermittent browser_context_menu_autocomplete_interaction.js. r=MattN MozReview-Commit-ID: 6vAWN4z2wRP
toolkit/components/passwordmgr/LoginManagerContent.jsm
toolkit/components/passwordmgr/test/browser/browser.ini
toolkit/components/satchel/nsFormFillController.cpp
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -5,17 +5,17 @@
 "use strict";
 
 this.EXPORTED_SYMBOLS = [ "LoginManagerContent",
                           "LoginFormFactory",
                           "UserAutoCompleteResult" ];
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 const PASSWORD_INPUT_ADDED_COALESCING_THRESHOLD_MS = 1;
-const AUTOCOMPLETE_AFTER_CONTEXTMENU_THRESHOLD_MS = 250;
+const AUTOCOMPLETE_AFTER_CONTEXTMENU_THRESHOLD_MS = 400;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 Cu.import("resource://gre/modules/InsecurePasswordUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Timer.jsm");
--- a/toolkit/components/passwordmgr/test/browser/browser.ini
+++ b/toolkit/components/passwordmgr/test/browser/browser.ini
@@ -35,16 +35,17 @@ support-files =
   subtst_notifications_1.html
   subtst_notifications_8.html
 [browser_capture_doorhanger_window_open.js]
 support-files =
   subtst_notifications_11.html
   subtst_notifications_11_popup.html
 skip-if = os == "linux" # Bug 1312981, bug 1313136
 [browser_context_menu_autocomplete_interaction.js]
+skip-if = asan || (os == 'linux' && debug && (bits == 32)) # disabled on asan and linux 32bit debug because of performance-related intermittents (see bug 1337772)
 [browser_username_select_dialog.js]
 support-files =
   subtst_notifications_change_p.html
 [browser_DOMFormHasPassword.js]
 [browser_DOMInputPasswordAdded.js]
 [browser_exceptions_dialog.js]
 [browser_formless_submit_chrome.js]
 [browser_hasInsecureLoginForms.js]
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -63,23 +63,24 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFormFi
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFormFillController)
 
 
 
 nsFormFillController::nsFormFillController() :
   mFocusedInput(nullptr),
   mFocusedInputNode(nullptr),
   mListNode(nullptr),
-  // This matches the threshold in
+  // The amount of time a context menu event supresses showing a
+  // popup from a focus event in ms. This matches the threshold in
   // toolkit/components/passwordmgr/LoginManagerContent.jsm.
-  mFocusAfterContextMenuThreshold(250),
+  mFocusAfterContextMenuThreshold(400),
   mTimeout(50),
   mMinResultsForPopup(1),
   mMaxRows(0),
-  mLastContextMenuEventTimeStamp(TimeStamp::Now()),
+  mLastContextMenuEventTimeStamp(TimeStamp()),
   mDisableAutoComplete(false),
   mCompleteDefaultIndex(false),
   mCompleteSelectedIndex(false),
   mForceComplete(false),
   mSuppressOnInput(false)
 {
   mController = do_GetService("@mozilla.org/autocomplete/controller;1");
   MOZ_ASSERT(mController);
@@ -1024,28 +1025,34 @@ nsFormFillController::MaybeStartControll
   }
 }
 
 void
 nsFormFillController::FocusEventDelayedCallback(nsIFormControl* aFormControl)
 {
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(mFocusedInputNode);
 
-  if (!formControl || formControl != aFormControl) {
+  if (!formControl || formControl != aFormControl ||
+      formControl->GetType() != NS_FORM_INPUT_PASSWORD) {
     return;
   }
 
+  // If we have not seen a context menu call yet, just show the popup.
+  if (mLastContextMenuEventTimeStamp.IsNull()) {
+   ShowPopup();
+   return;
+  }
+
   uint64_t timeDiff = fabs((TimeStamp::Now() - mLastContextMenuEventTimeStamp).ToMilliseconds());
   // If this focus doesn't follow a contextmenu event within our specified
   // threshold then show the autocomplete popup for all password fields.
   // This is done to avoid showing both the context menu and the popup
   // at the same time. The threshold should be a low amount of time that
   // makes it impossible for the user to accidentally trigger this condition.
-  if (timeDiff > mFocusAfterContextMenuThreshold
-      && formControl->GetType() == NS_FORM_INPUT_PASSWORD) {
+  if (timeDiff > mFocusAfterContextMenuThreshold) {
    ShowPopup();
   }
 }
 
 nsresult
 nsFormFillController::Focus(nsIDOMEvent* aEvent)
 {
   nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(