From 4642af4d8e3fb57ab76b27b6630c7fcd836f9363 Mon Sep 17 00:00:00 2001 From: Johann Hofmann Date: Wed, 1 Mar 2017 20:05:38 +0100 Subject: [PATCH] Bug 1337772 - Fix intermittent browser_context_menu_autocomplete_interaction.js. r=MattN MozReview-Commit-ID: 6vAWN4z2wRP --HG-- extra : rebase_source : d16b3d8e84dbaf0c9cdb30d9043286f829922c17 --- .../passwordmgr/LoginManagerContent.jsm | 2 +- .../passwordmgr/test/browser/browser.ini | 1 + .../satchel/nsFormFillController.cpp | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/toolkit/components/passwordmgr/LoginManagerContent.jsm b/toolkit/components/passwordmgr/LoginManagerContent.jsm index 2d03b648c607..4ed4328b064b 100644 --- a/toolkit/components/passwordmgr/LoginManagerContent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm @@ -10,7 +10,7 @@ this.EXPORTED_SYMBOLS = [ "LoginManagerContent", 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"); diff --git a/toolkit/components/passwordmgr/test/browser/browser.ini b/toolkit/components/passwordmgr/test/browser/browser.ini index 837fce97f2bd..4e7a2a81ac5c 100644 --- a/toolkit/components/passwordmgr/test/browser/browser.ini +++ b/toolkit/components/passwordmgr/test/browser/browser.ini @@ -40,6 +40,7 @@ support-files = 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 diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index 28f270b7235c..be3b2ca4934d 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -68,13 +68,14 @@ 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), @@ -1029,18 +1030,24 @@ nsFormFillController::FocusEventDelayedCallback(nsIFormControl* aFormControl) { nsCOMPtr 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(); } }