Bug 1792513: Do not show full list of Quick Actions while scrolling one off buttons. r=daleharvey,adw

Depends on D158220

Differential Revision: https://phabricator.services.mozilla.com/D158245
This commit is contained in:
Daisuke Akatsuka 2022-10-13 21:35:09 +00:00
parent 23568bc904
commit 9127c66b99
4 changed files with 54 additions and 2 deletions

View File

@ -2905,6 +2905,7 @@ export class UrlbarInput {
this._searchModeLabel.textContent = "";
this._searchModeIndicatorTitle.removeAttribute("data-l10n-id");
this._searchModeLabel.removeAttribute("data-l10n-id");
this.removeAttribute("searchmodesource");
if (!engineName && !source) {
try {
@ -2937,6 +2938,7 @@ export class UrlbarInput {
this.inputField,
`urlbar-placeholder-search-mode-other-${sourceName}`
);
this.setAttribute("searchmodesource", sourceName);
}
this.toggleAttribute("searchmode", true);

View File

@ -471,6 +471,22 @@ export var UrlbarTestUtils = {
"gURLBar.searchMode should exist as expected"
);
if (
window.gURLBar.searchMode?.source &&
window.gURLBar.searchMode.source !== UrlbarUtils.RESULT_SOURCE.SEARCH
) {
this.Assert.equal(
window.gURLBar.getAttribute("searchmodesource"),
UrlbarUtils.getResultSourceName(window.gURLBar.searchMode.source),
"gURLBar has proper searchmodesource attribute"
);
} else {
this.Assert.ok(
!window.gURLBar.hasAttribute("searchmodesource"),
"gURLBar does not have searchmodesource attribute"
);
}
if (!expectedSearchMode) {
// Check the input's placeholder.
const prefName =

View File

@ -105,8 +105,8 @@ add_task(async function enter_search_mode_button() {
window.document.getElementById("urlbar-engine-one-off-item-actions")
);
Assert.ok(oneOffButton, "One off button is available when preffed on");
EventUtils.synthesizeMouseAtCenter(oneOffButton, {}, window);
EventUtils.synthesizeMouseAtCenter(oneOffButton, {}, window);
await UrlbarTestUtils.assertSearchMode(window, {
source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
entry: "oneoff",
@ -115,6 +115,38 @@ add_task(async function enter_search_mode_button() {
await UrlbarTestUtils.waitForAutocompleteResultAt(window, 0);
Assert.ok(true, "Actions are shown when we enter actions search mode.");
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
EventUtils.synthesizeKey("KEY_Escape");
});
add_task(async function enter_search_mode_oneoff_by_key() {
// Select actions oneoff button by keyboard.
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
});
await UrlbarTestUtils.enterSearchMode(window);
const oneOffButtons = UrlbarTestUtils.getOneOffSearchButtons(window);
for (;;) {
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
if (
oneOffButtons.selectedButton.source === UrlbarUtils.RESULT_SOURCE.ACTIONS
) {
break;
}
}
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: " ",
});
await UrlbarTestUtils.assertSearchMode(window, {
source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
entry: "oneoff",
});
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
EventUtils.synthesizeKey("KEY_Escape");
});
@ -128,6 +160,8 @@ add_task(async function enter_search_mode_key() {
source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
entry: "typed",
});
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
EventUtils.synthesizeKey("KEY_Escape");
});

View File

@ -156,7 +156,7 @@
max-width: calc(100% - 28px - 1.8em);
}
#urlbar[searchmode] .urlbarView-row[dynamicType=quickactions] .urlbarView-dynamic-quickactions-buttons {
#urlbar[searchmodesource=actions] .urlbarView-row[dynamicType=quickactions] .urlbarView-dynamic-quickactions-buttons {
flex-wrap: wrap;
}