From 2b19541fd236eb9cf2a325a98f900c8b00860106 Mon Sep 17 00:00:00 2001 From: Harry Twyford Date: Thu, 12 Sep 2019 21:05:22 +0000 Subject: [PATCH] Bug 1580808 - Change UrlbarTestUtils.get[set]SelectedIndex to get[set]SelectedRowIndex. r=adw Depends on D45455 Differential Revision: https://phabricator.services.mozilla.com/D45724 --HG-- extra : moz-landing-system : lando --- .../urlbar/tests/UrlbarTestUtils.jsm | 4 +- .../browser/browser_autoFill_preserve.js | 2 +- .../browser_autocomplete_autoselect.js | 4 +- .../browser_autocomplete_edit_completed.js | 6 +-- ...rowser_autocomplete_readline_navigation.js | 2 +- .../tests/browser/browser_caret_navigation.js | 2 +- .../browser/browser_downArrowKeySearch.js | 6 +-- .../browser_keyword_select_and_type.js | 6 +-- .../browser/browser_restoreEmptyInput.js | 6 +-- .../browser/browser_selectStaleResults.js | 12 +++--- .../browser/browser_selectionKeyNavigation.js | 41 ++++++++++--------- .../browser/browser_switchTab_decodeuri.js | 2 +- .../browser/browser_switchTab_override.js | 2 +- ...wser_tabMatchesInAwesomebar_perwindowpb.js | 2 +- .../browser/browser_tip_keyboard_selection.js | 14 +++---- .../tests/browser/browser_urlbarDecode.js | 2 +- .../browser_urlbarEnterAfterMouseOver.js | 4 +- .../tests/browser/browser_urlbarOneOffs.js | 2 +- ...browser_urlbarOneOffs_searchSuggestions.js | 2 +- .../browser/browser_urlbar_remove_match.js | 4 +- .../browser/browser_UsageTelemetry_urlbar.js | 2 +- .../browser_ext_themes_autocomplete_popup.js | 4 +- 22 files changed, 67 insertions(+), 64 deletions(-) diff --git a/browser/components/urlbar/tests/UrlbarTestUtils.jsm b/browser/components/urlbar/tests/UrlbarTestUtils.jsm index 72b164c10a33..96bb1092ad4d 100644 --- a/browser/components/urlbar/tests/UrlbarTestUtils.jsm +++ b/browser/components/urlbar/tests/UrlbarTestUtils.jsm @@ -191,7 +191,7 @@ var UrlbarTestUtils = { * @param {object} win The window containing the urlbar. * @returns {number} The selected index. */ - getSelectedIndex(win) { + getSelectedRowIndex(win) { return win.gURLBar.view.selectedRowIndex; }, @@ -200,7 +200,7 @@ var UrlbarTestUtils = { * @param {object} win The window containing the urlbar. * @param {index} index The index to select. */ - setSelectedIndex(win, index) { + setSelectedRowIndex(win, index) { win.gURLBar.view.selectedRowIndex = index; }, diff --git a/browser/components/urlbar/tests/browser/browser_autoFill_preserve.js b/browser/components/urlbar/tests/browser/browser_autoFill_preserve.js index baec820606e6..89bb225cb0ea 100644 --- a/browser/components/urlbar/tests/browser/browser_autoFill_preserve.js +++ b/browser/components/urlbar/tests/browser/browser_autoFill_preserve.js @@ -215,7 +215,7 @@ add_task(async function backspaceNoAutofill() { function checkKeys(testTuples) { for (let [key, value, selectedIndex] of testTuples) { EventUtils.synthesizeKey(key); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), selectedIndex); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), selectedIndex); Assert.equal(gURLBar.untrimmedValue, value); } } diff --git a/browser/components/urlbar/tests/browser/browser_autocomplete_autoselect.js b/browser/components/urlbar/tests/browser/browser_autocomplete_autoselect.js index 55ffcc349645..5687a1b52bff 100644 --- a/browser/components/urlbar/tests/browser/browser_autocomplete_autoselect.js +++ b/browser/components/urlbar/tests/browser/browser_autocomplete_autoselect.js @@ -18,7 +18,7 @@ function repeat(limit, func) { function assertSelected(index) { Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), index, "Should have selected the correct item" ); @@ -49,7 +49,7 @@ function assertSelected_one_off(index) { // This is true because although both the listbox and the one-offs can have // selections, the test doesn't check that. Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), -1, "A one-off is selected, so the listbox should not have a selection" ); diff --git a/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js b/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js index 25e914be635c..9a7cf6c4657d 100644 --- a/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js +++ b/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js @@ -24,7 +24,7 @@ add_task(async function() { await promiseAutocompleteResultPopup("http://example.com"); - const initialIndex = UrlbarTestUtils.getSelectedIndex(window); + const initialIndex = UrlbarTestUtils.getSelectedRowIndex(window); info("Key Down to select the next item."); EventUtils.synthesizeKey("KEY_ArrowDown"); @@ -35,7 +35,7 @@ add_task(async function() { nextIndex ); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), nextIndex, "Should have selected the next item" ); @@ -51,7 +51,7 @@ add_task(async function() { let editedValue = gURLBar.value; Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), initialIndex, "Should have selected the initialIndex again" ); diff --git a/browser/components/urlbar/tests/browser/browser_autocomplete_readline_navigation.js b/browser/components/urlbar/tests/browser/browser_autocomplete_readline_navigation.js index ae9f241e004e..a991c9d62e22 100644 --- a/browser/components/urlbar/tests/browser/browser_autocomplete_readline_navigation.js +++ b/browser/components/urlbar/tests/browser/browser_autocomplete_readline_navigation.js @@ -17,7 +17,7 @@ function repeat(limit, func) { function assertSelected(index) { Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), index, "Should have the correct item selected" ); diff --git a/browser/components/urlbar/tests/browser/browser_caret_navigation.js b/browser/components/urlbar/tests/browser/browser_caret_navigation.js index 08f9db99b678..d126234ba893 100644 --- a/browser/components/urlbar/tests/browser/browser_caret_navigation.js +++ b/browser/components/urlbar/tests/browser/browser_caret_navigation.js @@ -76,7 +76,7 @@ async function checkPopupOpens(key) { checkIfKeyStartsQuery(key, true); }); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, `${key}: Heuristic result should be selected` ); diff --git a/browser/components/urlbar/tests/browser/browser_downArrowKeySearch.js b/browser/components/urlbar/tests/browser/browser_downArrowKeySearch.js index 086c0c3bcaed..e9fc6b9ec630 100644 --- a/browser/components/urlbar/tests/browser/browser_downArrowKeySearch.js +++ b/browser/components/urlbar/tests/browser/browser_downArrowKeySearch.js @@ -21,7 +21,7 @@ add_task(async function url() { gURLBar.selectionStart = gURLBar.untrimmedValue.length; EventUtils.synthesizeKey("KEY_ArrowDown"); await UrlbarTestUtils.promiseSearchComplete(window); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 0); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 0); let details = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); Assert.ok(details.autofill); Assert.equal(details.url, "http://example.com/"); @@ -35,7 +35,7 @@ add_task(async function userTyping() { await UrlbarTestUtils.promisePopupClose(window); EventUtils.synthesizeKey("KEY_ArrowDown"); await UrlbarTestUtils.promiseSearchComplete(window); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 0); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 0); let details = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); Assert.equal(details.type, UrlbarUtils.RESULT_TYPE.SEARCH); Assert.ok(details.searchParams); @@ -49,7 +49,7 @@ add_task(async function empty() { await UrlbarTestUtils.promisePopupClose(window); EventUtils.synthesizeKey("KEY_ArrowDown"); await UrlbarTestUtils.promiseSearchComplete(window); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), -1); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), -1); let details = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); Assert.equal(details.url, "http://example.com/"); Assert.equal(gURLBar.value, ""); diff --git a/browser/components/urlbar/tests/browser/browser_keyword_select_and_type.js b/browser/components/urlbar/tests/browser/browser_keyword_select_and_type.js index bcf6fac81a50..9db6ee4c17c7 100644 --- a/browser/components/urlbar/tests/browser/browser_keyword_select_and_type.js +++ b/browser/components/urlbar/tests/browser/browser_keyword_select_and_type.js @@ -47,7 +47,7 @@ add_task(async function() { // First item should already be selected Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "Should have the first item selected" ); @@ -55,7 +55,7 @@ add_task(async function() { // Select next one (important!) EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 1, "Should have the second item selected" ); @@ -63,7 +63,7 @@ add_task(async function() { // Re-select keyword item EventUtils.synthesizeKey("KEY_ArrowUp"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "Should have the first item selected" ); diff --git a/browser/components/urlbar/tests/browser/browser_restoreEmptyInput.js b/browser/components/urlbar/tests/browser/browser_restoreEmptyInput.js index c8169def2b0c..ad11b7ceb461 100644 --- a/browser/components/urlbar/tests/browser/browser_restoreEmptyInput.js +++ b/browser/components/urlbar/tests/browser/browser_restoreEmptyInput.js @@ -15,7 +15,7 @@ add_task(async function test() { await promiseAutocompleteResultPopup("", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), -1, "Nothing selected" ); @@ -27,7 +27,7 @@ add_task(async function test() { EventUtils.synthesizeKey("KEY_ArrowDown"); } Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), resultCount - 1, "Last result selected" ); @@ -35,7 +35,7 @@ add_task(async function test() { EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), -1, "Nothing selected" ); diff --git a/browser/components/urlbar/tests/browser/browser_selectStaleResults.js b/browser/components/urlbar/tests/browser/browser_selectStaleResults.js index 22d70e8d0b7e..07e7003c2372 100644 --- a/browser/components/urlbar/tests/browser/browser_selectStaleResults.js +++ b/browser/components/urlbar/tests/browser/browser_selectStaleResults.js @@ -104,20 +104,20 @@ add_task(async function viewContainsStaleRows() { // result, the stale "x" results should be selected. We should *not* enter // the one-off search buttons at that point. for (let i = 1; i < maxResults; i++) { - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, i); Assert.equal(result.element.row.result.uiIndex, i); EventUtils.synthesizeKey("KEY_ArrowDown"); } // Now the first one-off should be selected. - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), -1); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), -1); Assert.equal(gURLBar.view.oneOffSearchButtons.selectedButtonIndex, 0); // Arrow back up through all the results. for (let i = maxResults - 1; i >= 0; i--) { EventUtils.synthesizeKey("KEY_ArrowUp"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); } await UrlbarTestUtils.promisePopupClose(window, () => @@ -271,18 +271,18 @@ add_task(async function staleReplacedWithFresh() { // should continue on to "test2". We should *not* enter the one-off search // buttons at that point. for (let i = 1; i < maxResults; i++) { - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); EventUtils.synthesizeKey("KEY_ArrowDown"); } // Now the first one-off should be selected. - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), -1); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), -1); Assert.equal(gURLBar.view.oneOffSearchButtons.selectedButtonIndex, 0); // Arrow back up through all the results. for (let i = maxResults - 1; i >= 0; i--) { EventUtils.synthesizeKey("KEY_ArrowUp"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); } await UrlbarTestUtils.promisePopupClose(window, () => diff --git a/browser/components/urlbar/tests/browser/browser_selectionKeyNavigation.js b/browser/components/urlbar/tests/browser/browser_selectionKeyNavigation.js index ccf4a37f8eb9..509d5a40bca9 100644 --- a/browser/components/urlbar/tests/browser/browser_selectionKeyNavigation.js +++ b/browser/components/urlbar/tests/browser/browser_selectionKeyNavigation.js @@ -20,13 +20,13 @@ add_task(async function init() { add_task(async function downKey() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); for (let i = 1; i < MAX_RESULTS; i++) { EventUtils.synthesizeKey("KEY_ArrowDown"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); } EventUtils.synthesizeKey("KEY_ArrowDown"); let oneOffs = UrlbarTestUtils.getOneOffSearchButtons(window); @@ -35,7 +35,7 @@ add_task(async function downKey() { EventUtils.synthesizeKey("KEY_ArrowDown"); } Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected again" ); @@ -44,7 +44,7 @@ add_task(async function downKey() { add_task(async function upKey() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); @@ -55,20 +55,23 @@ add_task(async function upKey() { EventUtils.synthesizeKey("KEY_ArrowUp"); } Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), MAX_RESULTS - 1, "The last result should be selected" ); for (let i = 1; i < MAX_RESULTS; i++) { EventUtils.synthesizeKey("KEY_ArrowUp"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), MAX_RESULTS - i - 1); + Assert.equal( + UrlbarTestUtils.getSelectedRowIndex(window), + MAX_RESULTS - i - 1 + ); } }); add_task(async function pageDownKey() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); @@ -76,13 +79,13 @@ add_task(async function pageDownKey() { for (let i = 0; i < pageCount; i++) { EventUtils.synthesizeKey("KEY_PageDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), Math.min((i + 1) * UrlbarUtils.PAGE_UP_DOWN_DELTA, MAX_RESULTS - 1) ); } EventUtils.synthesizeKey("KEY_PageDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "Page down at end should wrap around to first result" ); @@ -91,13 +94,13 @@ add_task(async function pageDownKey() { add_task(async function pageUpKey() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); EventUtils.synthesizeKey("KEY_PageUp"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), MAX_RESULTS - 1, "Page up at start should wrap around to last result" ); @@ -105,7 +108,7 @@ add_task(async function pageUpKey() { for (let i = 0; i < pageCount; i++) { EventUtils.synthesizeKey("KEY_PageUp"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), Math.max(MAX_RESULTS - 1 - (i + 1) * UrlbarUtils.PAGE_UP_DOWN_DELTA, 0) ); } @@ -117,7 +120,7 @@ add_task(async function pageDownKeyShowsView() { EventUtils.synthesizeKey("KEY_PageDown"); await UrlbarTestUtils.promiseSearchComplete(window); Assert.ok(UrlbarTestUtils.isPopupOpen(window)); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 0); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 0); }); add_task(async function pageUpKeyShowsView() { @@ -126,23 +129,23 @@ add_task(async function pageUpKeyShowsView() { EventUtils.synthesizeKey("KEY_PageUp"); await UrlbarTestUtils.promiseSearchComplete(window); Assert.ok(UrlbarTestUtils.isPopupOpen(window)); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 0); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 0); }); add_task(async function tabKey() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); for (let i = 1; i < MAX_RESULTS; i++) { EventUtils.synthesizeKey("KEY_Tab"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), i); } EventUtils.synthesizeKey("KEY_Tab"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected again" ); @@ -151,13 +154,13 @@ add_task(async function tabKey() { add_task(async function tabKeyReverse() { await promiseAutocompleteResultPopup("exam", window, true); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The heuristic autofill result should be selected initially" ); for (let i = 1; i < MAX_RESULTS; i++) { EventUtils.synthesizeKey("KEY_Tab", { shiftKey: true }); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), MAX_RESULTS - i); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), MAX_RESULTS - i); } }); diff --git a/browser/components/urlbar/tests/browser/browser_switchTab_decodeuri.js b/browser/components/urlbar/tests/browser/browser_switchTab_decodeuri.js index ceed2d26651b..8b7b88093b10 100644 --- a/browser/components/urlbar/tests/browser/browser_switchTab_decodeuri.js +++ b/browser/components/urlbar/tests/browser/browser_switchTab_decodeuri.js @@ -24,7 +24,7 @@ add_task(async function test_switchtab_decodeuri() { EventUtils.synthesizeKey("KEY_ArrowDown"); let result = await UrlbarTestUtils.getDetailsOfResultAt( window, - UrlbarTestUtils.getSelectedIndex(window) + UrlbarTestUtils.getSelectedRowIndex(window) ); Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.TAB_SWITCH); diff --git a/browser/components/urlbar/tests/browser/browser_switchTab_override.js b/browser/components/urlbar/tests/browser/browser_switchTab_override.js index 006653e11812..11a63cbd3295 100644 --- a/browser/components/urlbar/tests/browser/browser_switchTab_override.js +++ b/browser/components/urlbar/tests/browser/browser_switchTab_override.js @@ -33,7 +33,7 @@ add_task(async function test_switchtab_override() { EventUtils.synthesizeKey("KEY_ArrowDown"); let result = await UrlbarTestUtils.getDetailsOfResultAt( window, - UrlbarTestUtils.getSelectedIndex(window) + UrlbarTestUtils.getSelectedRowIndex(window) ); Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.TAB_SWITCH); diff --git a/browser/components/urlbar/tests/browser/browser_tabMatchesInAwesomebar_perwindowpb.js b/browser/components/urlbar/tests/browser/browser_tabMatchesInAwesomebar_perwindowpb.js index 773e5c51b73d..78c959ec50fd 100644 --- a/browser/components/urlbar/tests/browser/browser_tabMatchesInAwesomebar_perwindowpb.js +++ b/browser/components/urlbar/tests/browser/browser_tabMatchesInAwesomebar_perwindowpb.js @@ -89,7 +89,7 @@ async function runTest(aSourceWindow, aDestWindow, aExpectSwitch, aCallback) { info(`awesomebar popup appeared. aExpectSwitch: ${aExpectSwitch}`); // Make sure the last match is selected. while ( - UrlbarTestUtils.getSelectedIndex(aDestWindow) < + UrlbarTestUtils.getSelectedRowIndex(aDestWindow) < UrlbarTestUtils.getResultCount(aDestWindow) - 1 ) { info("handling key navigation for DOM_VK_DOWN key"); diff --git a/browser/components/urlbar/tests/browser/browser_tip_keyboard_selection.js b/browser/components/urlbar/tests/browser/browser_tip_keyboard_selection.js index 99ce6b3f33c4..c33f6abb3761 100644 --- a/browser/components/urlbar/tests/browser/browser_tip_keyboard_selection.js +++ b/browser/components/urlbar/tests/browser/browser_tip_keyboard_selection.js @@ -100,7 +100,7 @@ add_task(async function tipIsSecondResult() { EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "The first result should be selected." ); @@ -113,7 +113,7 @@ add_task(async function tipIsSecondResult() { "The selected element should be the tip button." ); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 1, "getSelectedIndex should return 1 even though the tip button is selected." ); @@ -126,14 +126,14 @@ add_task(async function tipIsSecondResult() { "The selected element should be the tip help button." ); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 1, "getSelectedIndex should return 1 even though the help button is selected." ); EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 2, "The third result should be selected." ); @@ -194,7 +194,7 @@ add_task(async function tipIsOnlyResult() { "The selected element should be the tip button." ); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "getSelectedIndex should return 0." ); @@ -207,14 +207,14 @@ add_task(async function tipIsOnlyResult() { "The selected element should be the tip help button." ); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), 0, "getSelectedIndex should return 0." ); EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), -1, "There should be no selection." ); diff --git a/browser/components/urlbar/tests/browser/browser_urlbarDecode.js b/browser/components/urlbar/tests/browser/browser_urlbarDecode.js index 7532d7b12bae..84a64215e49f 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbarDecode.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarDecode.js @@ -63,7 +63,7 @@ add_task(async function actionURILosslessDecode() { // moz-action. do { EventUtils.synthesizeKey("KEY_ArrowDown"); - } while (UrlbarTestUtils.getSelectedIndex(window) != 0); + } while (UrlbarTestUtils.getSelectedRowIndex(window) != 0); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); diff --git a/browser/components/urlbar/tests/browser/browser_urlbarEnterAfterMouseOver.js b/browser/components/urlbar/tests/browser/browser_urlbarEnterAfterMouseOver.js index 39fe7bee9f5f..7fbcb25921b7 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbarEnterAfterMouseOver.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarEnterAfterMouseOver.js @@ -22,7 +22,7 @@ async function promiseAutoComplete(inputText) { function assertSelected(index) { Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), index, "Should have the correct index selected" ); @@ -56,7 +56,7 @@ add_task(async function() { "Should have got the correct amount of results" ); - let initiallySelected = UrlbarTestUtils.getSelectedIndex(window); + let initiallySelected = UrlbarTestUtils.getSelectedRowIndex(window); info("Key Down to select the next item"); EventUtils.synthesizeKey("KEY_ArrowDown"); diff --git a/browser/components/urlbar/tests/browser/browser_urlbarOneOffs.js b/browser/components/urlbar/tests/browser/browser_urlbarOneOffs.js index 2f954841dcce..74ad22030d3d 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbarOneOffs.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarOneOffs.js @@ -257,7 +257,7 @@ add_task(async function hiddenWhenUsingSearchAlias() { function assertState(result, oneOff, textValue = undefined) { Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), result, "Expected result should be selected" ); diff --git a/browser/components/urlbar/tests/browser/browser_urlbarOneOffs_searchSuggestions.js b/browser/components/urlbar/tests/browser/browser_urlbarOneOffs_searchSuggestions.js index d80215dd80c7..2bd998b630c0 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbarOneOffs_searchSuggestions.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarOneOffs_searchSuggestions.js @@ -194,7 +194,7 @@ add_task(async function overridden_engine_not_reused() { function assertState(result, oneOff, textValue = undefined) { Assert.equal( - UrlbarTestUtils.getSelectedIndex(window), + UrlbarTestUtils.getSelectedRowIndex(window), result, "Expected result should be selected" ); diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_remove_match.js b/browser/components/urlbar/tests/browser/browser_urlbar_remove_match.js index 43339b859f1b..a86972baa093 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbar_remove_match.js +++ b/browser/components/urlbar/tests/browser/browser_urlbar_remove_match.js @@ -23,7 +23,7 @@ add_task(async function test_remove_history() { let expectedResultCount = UrlbarTestUtils.getResultCount(window) - 1; EventUtils.synthesizeKey("KEY_ArrowDown"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 1); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 1); EventUtils.synthesizeKey("KEY_Delete", { shiftKey: true }); await promiseVisitRemoved; await TestUtils.waitForCondition( @@ -61,7 +61,7 @@ add_task(async function test_remove_bookmark_doesnt() { Assert.equal(result.url, TEST_URL, "Found the expected result"); EventUtils.synthesizeKey("KEY_ArrowDown"); - Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 1); + Assert.equal(UrlbarTestUtils.getSelectedRowIndex(window), 1); EventUtils.synthesizeKey("KEY_Delete", { shiftKey: true }); // We don't have an easy way of determining if the event was process or not, diff --git a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js index 2ca0a491daac..905c95e75871 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js @@ -740,7 +740,7 @@ add_task(async function test_suggestion_enterSelection() { let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("query"); info("Select the second result and press Return."); - UrlbarTestUtils.setSelectedIndex(window, 1); + UrlbarTestUtils.setSelectedRowIndex(window, 1); EventUtils.synthesizeKey("KEY_Enter"); await p; diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_autocomplete_popup.js b/toolkit/components/extensions/test/browser/browser_ext_themes_autocomplete_popup.js index ade1f9343799..40165e9ba332 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_autocomplete_popup.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_autocomplete_popup.js @@ -123,7 +123,7 @@ add_task(async function test_popup_url() { ); // Set the selected attribute to true to test the highlight popup properties - UrlbarTestUtils.setSelectedIndex(window, 1); + UrlbarTestUtils.setSelectedRowIndex(window, 1); let actionResult = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); let urlResult = await UrlbarTestUtils.getDetailsOfResultAt(window, 1); let resultCS = window.getComputedStyle(urlResult.element.row); @@ -142,7 +142,7 @@ add_task(async function test_popup_url() { // Now set the index to somewhere not on the first two, so that we can test both // url and action text colors. - UrlbarTestUtils.setSelectedIndex(window, 2); + UrlbarTestUtils.setSelectedRowIndex(window, 2); Assert.equal( window.getComputedStyle(urlResult.element.url).color,