Bug 1449018 - The bookmark panel should listen to keypress event at the system event group r=mak

The bookmark panel should handle keypress events at the system event group
because it needs to handle keypress events after autocomplete module which
handles keypress events at the system event group.

MozReview-Commit-ID: 9KjBlQ59gHw

--HG--
extra : rebase_source : 7a626d2b1bd7ae4f8fd917d5e569be34e34227dc
This commit is contained in:
Masayuki Nakano 2018-03-27 16:50:18 +09:00
Родитель 5cf2c64821
Коммит 989795493b
2 изменённых файлов: 83 добавлений и 1 удалений

Просмотреть файл

@ -32,7 +32,7 @@ var StarUI = {
// initially the panel is hidden
// to avoid impacting startup / new window performance
element.hidden = false;
element.addEventListener("keypress", this);
element.addEventListener("keypress", this, {mozSystemGroup: true});
element.addEventListener("mousedown", this);
element.addEventListener("mouseout", this);
element.addEventListener("mousemove", this);

Просмотреть файл

@ -442,6 +442,88 @@ add_task(async function ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() {
});
});
add_task(async function enter_during_autocomplete_should_prevent_autoclose() {
await test_bookmarks_popup({
isNewBookmark: true,
async popupShowFn(browser) {
EventUtils.synthesizeKey("d", {accelKey: true}, window);
},
async popupEditFn() {
let tagsField = document.getElementById("editBMPanel_tagsField");
tagsField.value = "";
tagsField.focus();
// Register a tag into the DB.
EventUtils.sendString("Abc", window);
tagsField.blur();
// Start autocomplete with the registered tag.
tagsField.value = "";
let popup = document.getElementById("PopupAutoComplete");
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
tagsField.focus();
EventUtils.sendString("a", window);
await promiseShown;
ok(promiseShown, "autocomplete shown");
// Select first candidate.
EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
// Type Enter key to choose the item.
EventUtils.synthesizeKey("KEY_Enter", {}, window);
Assert.equal(tagsField.value, "Abc",
"Autocomplete should've inserted the selected item");
},
shouldAutoClose: false,
popupHideFn() {
EventUtils.synthesizeKey("KEY_Escape", {}, window);
},
isBookmarkRemoved: false,
});
});
add_task(async function escape_during_autocomplete_should_prevent_autoclose() {
await test_bookmarks_popup({
isNewBookmark: true,
async popupShowFn(browser) {
EventUtils.synthesizeKey("d", {accelKey: true}, window);
},
async popupEditFn() {
let tagsField = document.getElementById("editBMPanel_tagsField");
tagsField.value = "";
tagsField.focus();
// Register a tag into the DB.
EventUtils.sendString("Abc", window);
tagsField.blur();
// Start autocomplete with the registered tag.
tagsField.value = "";
let popup = document.getElementById("PopupAutoComplete");
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
tagsField.focus();
EventUtils.sendString("a", window);
await promiseShown;
ok(promiseShown, "autocomplete shown");
// Select first candidate.
EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
// Type Enter key to choose the item.
EventUtils.synthesizeKey("KEY_Escape", {}, window);
Assert.equal(tagsField.value, "Abc",
"Autocomplete should've inserted the selected item and shouldn't clear it");
},
shouldAutoClose: false,
popupHideFn() {
EventUtils.synthesizeKey("KEY_Escape", {}, window);
},
isBookmarkRemoved: false,
});
});
registerCleanupFunction(function() {
delete StarUI._closePanelQuickForTesting;
});