mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 1042561 - Implement stopAutoCompleteSearch() for FormAutoCompleteChild to prevent e10s tests from running into assertions r=mak
This commit is contained in:
parent
caebf28f30
commit
8015817bc5
@ -335,6 +335,7 @@ FormAutoCompleteChild.prototype = {
|
||||
|
||||
_debug: false,
|
||||
_enabled: true,
|
||||
_pendingSearch: null,
|
||||
|
||||
/*
|
||||
* init
|
||||
@ -367,7 +368,9 @@ FormAutoCompleteChild.prototype = {
|
||||
autoCompleteSearchAsync : function (aInputName, aUntrimmedSearchString, aField, aPreviousResult, aListener) {
|
||||
this.log("autoCompleteSearchAsync");
|
||||
|
||||
this._pendingListener = aListener;
|
||||
if (this._pendingSearch) {
|
||||
this.stopAutoCompleteSearch();
|
||||
}
|
||||
|
||||
let rect = BrowserUtils.getElementBoundingScreenRect(aField);
|
||||
|
||||
@ -389,26 +392,35 @@ FormAutoCompleteChild.prototype = {
|
||||
height: rect.height
|
||||
});
|
||||
|
||||
mm.addMessageListener("FormAutoComplete:AutoCompleteSearchAsyncResult",
|
||||
function searchFinished(message) {
|
||||
mm.removeMessageListener("FormAutoComplete:AutoCompleteSearchAsyncResult", searchFinished);
|
||||
let result = new FormAutoCompleteResult(
|
||||
null,
|
||||
[{text: res} for (res of message.data.results)],
|
||||
null,
|
||||
null
|
||||
);
|
||||
if (aListener) {
|
||||
aListener.onSearchCompletion(result);
|
||||
}
|
||||
}
|
||||
);
|
||||
let search = this._pendingSearch = {};
|
||||
let searchFinished = message => {
|
||||
mm.removeMessageListener("FormAutoComplete:AutoCompleteSearchAsyncResult", searchFinished);
|
||||
|
||||
// Check whether stopAutoCompleteSearch() was called, i.e. the search
|
||||
// was cancelled, while waiting for a result.
|
||||
if (search != this._pendingSearch) {
|
||||
return;
|
||||
}
|
||||
this._pendingSearch = null;
|
||||
|
||||
let result = new FormAutoCompleteResult(
|
||||
null,
|
||||
[for (res of message.data.results) {text: res}],
|
||||
null,
|
||||
null
|
||||
);
|
||||
if (aListener) {
|
||||
aListener.onSearchCompletion(result);
|
||||
}
|
||||
}
|
||||
|
||||
mm.addMessageListener("FormAutoComplete:AutoCompleteSearchAsyncResult", searchFinished);
|
||||
this.log("autoCompleteSearchAsync message was sent");
|
||||
},
|
||||
|
||||
stopAutoCompleteSearch : function () {
|
||||
this.log("stopAutoCompleteSearch");
|
||||
this.log("stopAutoCompleteSearch");
|
||||
this._pendingSearch = null;
|
||||
},
|
||||
}; // end of FormAutoCompleteChild implementation
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user