Bug 1504880 - Intermittent failure in browser_autocomplete_enter_race.js. r=Standard8
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 03 Jan 2019 08:35:52 +0000
changeset 509483 a29627aa1ef5977bff1e93dcd150a274cfe79e15
parent 509482 a97b9b4c385e526301358abadfe1eb9039312d8b
child 509484 c5d46599eb99b0edacc1b29b66814189a0ab8423
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1504880
milestone66.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 1504880 - Intermittent failure in browser_autocomplete_enter_race.js. r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D15237
browser/base/content/test/urlbar/browser.ini
browser/base/content/urlbarBindings.xml
toolkit/content/widgets/autocomplete.xml
--- a/browser/base/content/test/urlbar/browser.ini
+++ b/browser/base/content/test/urlbar/browser.ini
@@ -14,17 +14,16 @@ support-files =
 [browser_action_searchengine_alias.js]
 [browser_autocomplete_a11y_label.js]
 skip-if = (verify && !debug && (os == 'win'))
 [browser_autocomplete_autoselect.js]
 [browser_autocomplete_cursor.js]
 skip-if = verify
 [browser_autocomplete_edit_completed.js]
 [browser_autocomplete_enter_race.js]
-skip-if = true # Bug 1504880
 [browser_autocomplete_no_title.js]
 [browser_autocomplete_readline_navigation.js]
 skip-if = os != "mac" # Mac only feature
 [browser_autocomplete_tag_star_visibility.js]
 [browser_bug1104165-switchtab-decodeuri.js]
 [browser_bug1003461-switchtab-override.js]
 skip-if = (verify && debug && (os == 'win'))
 [browser_bug1024133-switchtab-override-keynav.js]
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -287,17 +287,17 @@ file, You can obtain one at http://mozil
             this.removeAttribute("actiontype");
           }
           return returnValue;
         ]]></body>
       </method>
 
       <method name="onKeyPress">
         <parameter name="aEvent"/>
-        <parameter name="aNoDefer"/>
+        <parameter name="aOptions"/>
         <body><![CDATA[
           switch (aEvent.keyCode) {
             case KeyEvent.DOM_VK_LEFT:
             case KeyEvent.DOM_VK_RIGHT:
             case KeyEvent.DOM_VK_HOME:
               // Reset the selected index so that nsAutoCompleteController
               // simply closes the popup without trying to fill anything.
               this.popup.selectedIndex = -1;
@@ -328,24 +328,25 @@ file, You can obtain one at http://mozil
                   // The user is explicitly making a selection, so the popup
                   // should get accessibility focus.
                   this.popup.richlistbox.suppressMenuItemEvent = false;
                 }
                 break;
             }
           }
 
-          if (!aNoDefer && this._shouldDeferKeyEvent(aEvent)) {
+          let noDefer = aOptions && aOptions.noDefer;
+          if (!noDefer && this._shouldDeferKeyEvent(aEvent)) {
             this._deferKeyEvent(aEvent, "onKeyPress");
             return false;
           }
           if (this.popup.popupOpen && this.popup.handleKeyPress(aEvent)) {
             return true;
           }
-          return this.handleKeyPress(aEvent);
+          return this.handleKeyPress(aEvent, aOptions);
         ]]></body>
       </method>
 
       <!--
         Search results arrive asynchronously, which means that keypresses may
         arrive before results do and therefore not have the effect the user
         intends.  That's especially likely to happen with the down arrow and
         enter keys due to the one-off search buttons: if the user very quickly
@@ -450,19 +451,21 @@ file, You can obtain one at http://mozil
 
       <!--
         Adds a key event to the deferred event queue.
 
         @param event
                The key event to defer.
         @param methodName
                The name of the method on `this` to call.  It's expected to take
-               two arguments: the event, and a noDefer bool.  If the bool is
-               true, then the event is being replayed and it should not be
-               deferred.
+               two arguments: the event, and an optional options object:
+               {
+                  noDefer: If true, then the event is being replayed and it
+                           should not be deferred again.
+               }
       -->
       <method name="_deferKeyEvent">
         <parameter name="event"/>
         <parameter name="methodName"/>
         <body><![CDATA[
           // Somehow event.defaultPrevented ends up true for deferred events.
           // autocomplete ignores defaultPrevented events, which means it would
           // ignore replayed deferred events if we didn't tell it to bypass
@@ -544,17 +547,17 @@ file, You can obtain one at http://mozil
         ]]></body>
       </method>
 
       <method name="_replayKeyEventInstance">
         <parameter name="instance"/>
         <body><![CDATA[
           // Safety check: handle only if the search string didn't change.
           if (this.mController.searchString == instance.searchString) {
-            this[instance.methodName](instance.event, true);
+            this[instance.methodName](instance.event, {noDefer: true});
           }
         ]]></body>
       </method>
 
       <field name="_mayTrimURLs">true</field>
       <method name="trimValue">
         <parameter name="aURL"/>
         <body><![CDATA[
@@ -1518,17 +1521,17 @@ file, You can obtain one at http://mozil
             }
           }
           this.resetActionType();
         ]]></body>
       </method>
 
       <method name="handleEnter">
         <parameter name="event"/>
-        <parameter name="noDefer"/>
+        <parameter name="options"/>
         <body><![CDATA[
           // We need to ensure we're using a selected autocomplete result.
           // A result should automatically be selected by default,
           // however autocomplete is async and therefore we may not
           // have a result set relating to the current input yet. If that
           // happens, we need to mark that when the first result does get added,
           // it needs to be handled as if enter was pressed with that first
           // result selected.
@@ -1538,16 +1541,17 @@ file, You can obtain one at http://mozil
           // input.
           // However, if the default result is automatically selected, we
           // ensure that it corresponds to the current input.
 
           // Store the current search string so it can be used in handleCommand,
           // which will be called as a result of mController.handleEnter().
           this.handleEnterSearchString = this.mController.searchString;
 
+          let noDefer = options && options.noDefer;
           if (!noDefer && this._shouldDeferKeyEvent(event)) {
             // Defer the event until the first non-heuristic result comes in.
             this._deferKeyEvent(event, "handleEnter");
             return false;
           }
 
           let canonizeValue = this.value;
           if (event.ctrlKey) {
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -391,16 +391,17 @@
         <parameter name="aEvent"/>
         <body><![CDATA[
           return this.handleKeyPress(aEvent);
         ]]></body>
       </method>
 
       <method name="handleKeyPress">
         <parameter name="aEvent"/>
+        <parameter name="aOptions"/>
         <body><![CDATA[
           if (aEvent.target.localName != "textbox")
             return true; // Let child buttons of autocomplete take input
 
           // Re: urlbarDeferred, see the comment in urlbarBindings.xml.
           if (aEvent.defaultPrevented && !aEvent.urlbarDeferred) {
             return false;
           }
@@ -467,17 +468,17 @@
                   aEvent.preventDefault();
               }
               if (this.popup.selectedIndex >= 0) {
                 this._selectionDetails = {
                   index: this.popup.selectedIndex,
                   kind: "key",
                 };
               }
-              cancel = this.handleEnter(aEvent);
+              cancel = this.handleEnter(aEvent, aOptions);
               break;
             case KeyEvent.DOM_VK_DELETE:
               if (isMac && !aEvent.shiftKey) {
                 break;
               }
               cancel = this.handleDelete();
               break;
             case KeyEvent.DOM_VK_BACK_SPACE: