Bug 1595875, fix handling of return value of FormAutoComplete:GetSelectedIndex that was incorrectly removed by 1573836, r=MattN
authorNeil Deakin <neil@mozilla.com>
Thu, 14 Nov 2019 10:07:52 +0000
changeset 501947 3073a3b8530c1d0b1d23bc1a05f7853a9c5eb786
parent 501946 d715026b63988d05911e04a6fed6c18be47f6683
child 501948 393442f15e7de96ea6e34cee4fe722f60fab1532
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1595875, 1573836
milestone72.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 1595875, fix handling of return value of FormAutoComplete:GetSelectedIndex that was incorrectly removed by 1573836, r=MattN Differential Revision: https://phabricator.services.mozilla.com/D52720
toolkit/actors/AutoCompleteChild.jsm
--- a/toolkit/actors/AutoCompleteChild.jsm
+++ b/toolkit/actors/AutoCompleteChild.jsm
@@ -177,19 +177,30 @@ class AutoCompleteChild extends JSWindow
 
   get selectedIndex() {
     // selectedIndex getter must be synchronous because we need the
     // correct value when the controller is in controller::HandleEnter.
     // We can't easily just let the parent inform us the new value every
     // time it changes because not every action that can change the
     // selectedIndex is trivial to catch (e.g. moving the mouse over the
     // list).
-    return Services.cpmm.sendSyncMessage("FormAutoComplete:GetSelectedIndex", {
-      browsingContext: this.browsingContext,
-    });
+    let selectedIndexResult = Services.cpmm.sendSyncMessage(
+      "FormAutoComplete:GetSelectedIndex",
+      {
+        browsingContext: this.browsingContext,
+      }
+    );
+
+    if (
+      selectedIndexResult.length != 1 ||
+      !Number.isInteger(selectedIndexResult[0])
+    ) {
+      throw new Error("Invalid autocomplete selectedIndex");
+    }
+    return selectedIndexResult[0];
   }
 
   get popupOpen() {
     return this._popupOpen;
   }
 
   openAutocompletePopup(input, element) {
     if (this._popupOpen || !input) {