зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1115616
- Part 2: Commit composition string forcibly when search suggestion list is clicked in about:home. r=adw
This commit is contained in:
Родитель
148f9de559
Коммит
777657f883
|
@ -240,16 +240,11 @@ SearchSuggestionUIController.prototype = {
|
|||
|
||||
// Commit composition string forcibly, because setting input value does not
|
||||
// work if input has composition string (see bug 1115616 and bug 632744).
|
||||
try {
|
||||
let imeEditor = this.input.editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);
|
||||
if (imeEditor.composing) {
|
||||
// Ignore input event for compisition end to avoid getting suggestion
|
||||
// again.
|
||||
this._ignoreInputEvent = true;
|
||||
imeEditor.forceCompositionEnd();
|
||||
this._ignoreInputEvent = false;
|
||||
}
|
||||
} catch(e) { }
|
||||
// Ignore input event for composition end to avoid getting suggestion again.
|
||||
this._ignoreInputEvent = true;
|
||||
this.input.blur();
|
||||
this.input.focus();
|
||||
this._ignoreInputEvent = false;
|
||||
|
||||
this.input.value = suggestion;
|
||||
this.input.setAttribute("selection-index", idx);
|
||||
|
|
|
@ -380,6 +380,56 @@ let gTests = [
|
|||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "Clicking suggestion list while composing",
|
||||
setup: function() {},
|
||||
run: function()
|
||||
{
|
||||
return Task.spawn(function* () {
|
||||
// Start composition and type "x"
|
||||
let input = gBrowser.contentDocument.getElementById("searchText");
|
||||
input.focus();
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart", data: "" });
|
||||
EventUtils.synthesizeComposition({ type: "compositionupdate", data: "x" });
|
||||
EventUtils.synthesizeCompositionChange({
|
||||
composition: {
|
||||
string: "x",
|
||||
clauses: [
|
||||
{ length: 1, attr: EventUtils.COMPOSITION_ATTR_RAWINPUT }
|
||||
]
|
||||
},
|
||||
caret: { start: 1, length: 0 }
|
||||
});
|
||||
|
||||
// Wait for the search suggestions to become visible.
|
||||
let table =
|
||||
gBrowser.contentDocument.getElementById("searchSuggestionTable");
|
||||
let deferred = Promise.defer();
|
||||
let observer = new MutationObserver(() => {
|
||||
if (input.getAttribute("aria-expanded") == "true") {
|
||||
observer.disconnect();
|
||||
ok(!table.hidden, "Search suggestion table unhidden");
|
||||
deferred.resolve();
|
||||
}
|
||||
});
|
||||
observer.observe(input, {
|
||||
attributes: true,
|
||||
attributeFilter: ["aria-expanded"],
|
||||
});
|
||||
yield deferred.promise;
|
||||
|
||||
// Click the second suggestion.
|
||||
let expectedURL = Services.search.currentEngine.
|
||||
getSubmission("xbar", null, "homepage").
|
||||
uri.spec;
|
||||
let loadPromise = waitForDocLoadAndStopIt(expectedURL);
|
||||
let row = table.children[1];
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, row, gBrowser.contentWindow);
|
||||
yield loadPromise;
|
||||
ok(input.value == "xbar", "Suggestion is selected");
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "Cmd+k should focus the search box in the page when the search box in the toolbar is absent",
|
||||
setup: function () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче