Bug 1811870 - Enable urlbar result menu in Nightly. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D167693
This commit is contained in:
Dão Gottwald 2023-01-28 14:22:46 +00:00
Родитель 11a4f4323e
Коммит 98f679da17
7 изменённых файлов: 73 добавлений и 41 удалений

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

@ -503,7 +503,11 @@ pref("browser.urlbar.switchTabs.adoptIntoActiveWindow", false);
pref("browser.urlbar.openintab", false); pref("browser.urlbar.openintab", false);
// Enable three-dot options button and menu for eligible results. // Enable three-dot options button and menu for eligible results.
#ifdef NIGHTLY_BUILD
pref("browser.urlbar.resultMenu", true);
#else
pref("browser.urlbar.resultMenu", false); pref("browser.urlbar.resultMenu", false);
#endif
// If true, we show tail suggestions when available. // If true, we show tail suggestions when available.
pref("browser.urlbar.richSuggestions.tail", true); pref("browser.urlbar.richSuggestions.tail", true);

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

@ -72,27 +72,25 @@ add_task(async function keyboardSelection_secondResult() {
); );
await assertIsTestResult(1); await assertIsTestResult(1);
let resultMenuOffset = UrlbarPrefs.get("resultMenu") ? 1 : 0;
info("Arrow down to the main part of the result."); info("Arrow down to the main part of the result.");
EventUtils.synthesizeKey("KEY_ArrowDown"); EventUtils.synthesizeKey("KEY_ArrowDown");
assertMainPartSelected(1 + resultMenuOffset); assertMainPartSelected(1);
info("TAB to the button."); info("TAB to the button.");
EventUtils.synthesizeKey("KEY_Tab"); EventUtils.synthesizeKey("KEY_Tab");
assertButtonSelected(2 + resultMenuOffset); assertButtonSelected(2);
info("TAB to the next (third) result."); info("TAB to the next (third) result.");
EventUtils.synthesizeKey("KEY_Tab"); EventUtils.synthesizeKey("KEY_Tab");
assertOtherResultSelected(3 + resultMenuOffset, "next result"); assertOtherResultSelected(3, "next result");
info("SHIFT+TAB to the help button."); info("SHIFT+TAB to the help button.");
EventUtils.synthesizeKey("KEY_Tab", { shiftKey: true }); EventUtils.synthesizeKey("KEY_Tab", { shiftKey: true });
assertButtonSelected(2 + resultMenuOffset); assertButtonSelected(2);
info("SHIFT+TAB to the main part of the result."); info("SHIFT+TAB to the main part of the result.");
EventUtils.synthesizeKey("KEY_Tab", { shiftKey: true }); EventUtils.synthesizeKey("KEY_Tab", { shiftKey: true });
assertMainPartSelected(1 + resultMenuOffset); assertMainPartSelected(1);
info("Arrow up to the previous (first) result."); info("Arrow up to the previous (first) result.");
EventUtils.synthesizeKey("KEY_ArrowUp"); EventUtils.synthesizeKey("KEY_ArrowUp");
@ -125,7 +123,7 @@ add_task(async function keyboardSelection_lastResult() {
await assertIsTestResult(MAX_RESULTS - 1); await assertIsTestResult(MAX_RESULTS - 1);
let numSelectable = UrlbarPrefs.get("resultMenu") let numSelectable = UrlbarPrefs.get("resultMenu")
? MAX_RESULTS * 2 - 1 ? MAX_RESULTS * 2 - 2
: MAX_RESULTS; : MAX_RESULTS;
// Arrow down to the main part of the result. // Arrow down to the main part of the result.
@ -220,7 +218,9 @@ async function doPickTest({ pickButton, useKeyboard }) {
if (useKeyboard) { if (useKeyboard) {
// Arrow down to the result. // Arrow down to the result.
EventUtils.synthesizeKey("KEY_ArrowDown", { repeat: index }); EventUtils.synthesizeKey("KEY_ArrowDown", { repeat: index });
assertMainPartSelected(UrlbarPrefs.get("resultMenu") ? index * 2 : index); assertMainPartSelected(
UrlbarPrefs.get("resultMenu") ? index * 2 - 1 : index
);
} }
// Pick the result. The appropriate URL should load. // Pick the result. The appropriate URL should load.

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

@ -297,7 +297,13 @@ async function expectTabThroughResults(options = { reverse: false }) {
for (let i = initiallySelectedIndex + 1; i < resultCount; i++) { for (let i = initiallySelectedIndex + 1; i < resultCount; i++) {
EventUtils.synthesizeKey("KEY_Tab", { shiftKey: options.reverse }); EventUtils.synthesizeKey("KEY_Tab", { shiftKey: options.reverse });
if (UrlbarTestUtils.getButtonForResultIndex(window, "menu")) { if (
UrlbarTestUtils.getButtonForResultIndex(
window,
"menu",
UrlbarTestUtils.getSelectedRowIndex(window)
)
) {
EventUtils.synthesizeKey("KEY_Tab", { shiftKey: options.reverse }); EventUtils.synthesizeKey("KEY_Tab", { shiftKey: options.reverse });
} }
Assert.equal( Assert.equal(
@ -306,9 +312,7 @@ async function expectTabThroughResults(options = { reverse: false }) {
); );
} }
EventUtils.synthesizeKey("KEY_Tab", { EventUtils.synthesizeKey("KEY_Tab");
repeat: UrlbarPrefs.get("resultMenu") && result.heuristic ? 2 : 1,
});
if (!options.reverse) { if (!options.reverse) {
Assert.equal( Assert.equal(

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

@ -142,9 +142,7 @@ add_task(async function activedescendant_tab() {
"The second result is a tab-to-search result." "The second result is a tab-to-search result."
); );
EventUtils.synthesizeKey("KEY_Tab", { EventUtils.synthesizeKey("KEY_Tab");
repeat: UrlbarPrefs.get("resultMenu") ? 2 : 1,
});
await UrlbarTestUtils.assertSearchMode(window, { await UrlbarTestUtils.assertSearchMode(window, {
engineName: TEST_ENGINE_NAME, engineName: TEST_ENGINE_NAME,
@ -164,9 +162,7 @@ add_task(async function activedescendant_tab() {
firstRow._content.id, firstRow._content.id,
"aria-activedescendant was set to the row after the tab-to-search result." "aria-activedescendant was set to the row after the tab-to-search result."
); );
EventUtils.synthesizeKey("KEY_Tab", { EventUtils.synthesizeKey("KEY_Tab");
repeat: UrlbarPrefs.get("resultMenu") ? 2 : 1,
});
aadID = gURLBar.inputField.getAttribute("aria-activedescendant"); aadID = gURLBar.inputField.getAttribute("aria-activedescendant");
Assert.equal( Assert.equal(
aadID, aadID,
@ -190,9 +186,7 @@ add_task(async function activedescendant_tab() {
"The second result is a tab-to-search result." "The second result is a tab-to-search result."
); );
EventUtils.synthesizeKey("KEY_Tab", { EventUtils.synthesizeKey("KEY_Tab");
repeat: UrlbarPrefs.get("resultMenu") ? 2 : 1,
});
await UrlbarTestUtils.assertSearchMode(window, { await UrlbarTestUtils.assertSearchMode(window, {
engineName: TEST_ENGINE_NAME, engineName: TEST_ENGINE_NAME,

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

@ -236,8 +236,8 @@ const tests = [
info("Selecting a tip's main button, enter."); info("Selecting a tip's main button, enter.");
win.gURLBar.search("x"); win.gURLBar.search("x");
await UrlbarTestUtils.promiseSearchComplete(win); await UrlbarTestUtils.promiseSearchComplete(win);
EventUtils.synthesizeKey("KEY_Tab", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
EventUtils.synthesizeKey("KEY_Tab", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
unregisterTipProvider(tipProvider); unregisterTipProvider(tipProvider);
return { return {
@ -257,13 +257,20 @@ const tests = [
}, },
async function(win) { async function(win) {
if (UrlbarPrefs.get("resultMenu")) {
todo(
false,
"telemetry for the result menu to be implemented in bug 1790020"
);
return null;
}
let tipProvider = registerTipProvider(); let tipProvider = registerTipProvider();
info("Selecting a tip's help button, enter."); info("Selecting a tip's help button, enter.");
let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser); let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
win.gURLBar.search("x"); win.gURLBar.search("x");
await UrlbarTestUtils.promiseSearchComplete(win); await UrlbarTestUtils.promiseSearchComplete(win);
EventUtils.synthesizeKey("KEY_Tab", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
EventUtils.synthesizeKey("KEY_Tab", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
EventUtils.synthesizeKey("KEY_Tab", {}, win); EventUtils.synthesizeKey("KEY_Tab", {}, win);
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
@ -1191,6 +1198,10 @@ async function doTest(eventTelemetryEnabled) {
for (let i = 0; i < tests.length; i++) { for (let i = 0; i < tests.length; i++) {
info(`Running test at index ${i}`); info(`Running test at index ${i}`);
let events = await tests[i](win); let events = await tests[i](win);
if (events === null) {
info("Skipping test");
continue;
}
if (!Array.isArray(events)) { if (!Array.isArray(events)) {
events = [events]; events = [events];
} }

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

@ -322,6 +322,13 @@ add_task(async function withDnsFirstForSingleWordsPref() {
}); });
add_task(async function buttons() { add_task(async function buttons() {
if (UrlbarPrefs.get("resultMenu")) {
todo(
false,
"the menu button is only visible on hover, so not as easily testable as the block and help buttons."
);
return;
}
let initialTabUrl = "https://example.com/initial"; let initialTabUrl = "https://example.com/initial";
let mainResultUrl = "https://example.com/main"; let mainResultUrl = "https://example.com/main";
let mainResultHelpUrl = "https://example.com/help"; let mainResultHelpUrl = "https://example.com/help";
@ -599,17 +606,7 @@ async function waitForElements(selectors) {
let elements; let elements;
await BrowserTestUtils.waitForCondition(() => { await BrowserTestUtils.waitForCondition(() => {
elements = selectors.map(s => document.querySelector(s)); elements = selectors.map(s => document.querySelector(s));
return elements.every(e => { return elements.every(e => e && BrowserTestUtils.is_visible(e));
if (e?.classList.contains("urlbarView-button-menu")) {
// Hover the row to make the menu button visible.
let row = e.closest(".urlbarView-row");
EventUtils.synthesizeMouse(row, 1, 1, { type: "mouseover" });
EventUtils.synthesizeMouse(row, 2, 2, { type: "mousemove" });
EventUtils.synthesizeMouse(row, 3, 3, { type: "mousemove" });
EventUtils.synthesizeMouse(row, 4, 4, { type: "mousemove" });
}
return e && BrowserTestUtils.is_visible(e);
});
}, "Waiting for elements to become visible: " + JSON.stringify(selectors)); }, "Waiting for elements to become visible: " + JSON.stringify(selectors));
return elements; return elements;
} }

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

@ -66,12 +66,23 @@ add_task(async function engagement_type_dismiss() {
const originalResultCount = UrlbarTestUtils.getResultCount(window); const originalResultCount = UrlbarTestUtils.getResultCount(window);
await selectRowByURL("https://example.com/sponsored"); await selectRowByURL("https://example.com/sponsored");
doClickSubButton(".urlbarView-button-block"); if (UrlbarPrefs.get("resultMenu")) {
UrlbarTestUtils.openResultMenuAndPressAccesskey(window, "D");
} else {
doClickSubButton(".urlbarView-button-block");
}
await BrowserTestUtils.waitForCondition( await BrowserTestUtils.waitForCondition(
() => originalResultCount != UrlbarTestUtils.getResultCount(window) () => originalResultCount != UrlbarTestUtils.getResultCount(window)
); );
assertEngagementTelemetry([{ engagement_type: "dismiss" }]); if (UrlbarPrefs.get("resultMenu")) {
todo(
false,
"telemetry for the result menu to be implemented in bug 1790020"
);
} else {
assertEngagementTelemetry([{ engagement_type: "dismiss" }]);
}
}); });
await doTest(async browser => { await doTest(async browser => {
@ -105,11 +116,22 @@ add_task(async function engagement_type_help() {
await openPopup("sponsored"); await openPopup("sponsored");
await selectRowByURL("https://example.com/sponsored"); await selectRowByURL("https://example.com/sponsored");
const onTabOpened = BrowserTestUtils.waitForNewTab(gBrowser); const onTabOpened = BrowserTestUtils.waitForNewTab(gBrowser);
doClickSubButton(".urlbarView-button-help"); if (UrlbarPrefs.get("resultMenu")) {
UrlbarTestUtils.openResultMenuAndPressAccesskey(window, "L");
} else {
doClickSubButton(".urlbarView-button-help");
}
const tab = await onTabOpened; const tab = await onTabOpened;
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
assertEngagementTelemetry([{ engagement_type: "help" }]); if (UrlbarPrefs.get("resultMenu")) {
todo(
false,
"telemetry for the result menu to be implemented in bug 1790020"
);
} else {
assertEngagementTelemetry([{ engagement_type: "help" }]);
}
}); });
await SpecialPowers.popPrefEnv(); await SpecialPowers.popPrefEnv();