diff --git a/toolkit/actors/AutoCompleteChild.jsm b/toolkit/actors/AutoCompleteChild.jsm index 5030e83215b8..782a0fc8057b 100644 --- a/toolkit/actors/AutoCompleteChild.jsm +++ b/toolkit/actors/AutoCompleteChild.jsm @@ -182,9 +182,20 @@ class AutoCompleteChild extends JSWindowActorChild { // 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() {