Bug 1833161 - Properly restore selection when showing the dismissal acknowledgment tip. r=ahal,dao
The problem is the row remains selected after its content is replaced with the dismissal acknowledgment tip. This patch clears the selection and selects the tip's "Got it" button if the row was selected. I didn't add a general browser test for feedback and dismissal acknowledgments earlier, so I added one now. I cp'ed the weather test and used it as a starting point since it does test the acknowledgments but is specific to the weather suggestion. Even though some of it now duplicates the new test, I left it intact because we still need a test for the weather-specific commands, and the amount of duplicated code isn't very much. I modified the test helper function that opens the result menu so that the row is not selected when `byMouse` is true. That way I can make sure the selection doesn't change when the dismissed row is not selected. I used `EventUtils.promiseElementReadyForUserInput()` to synthesize a mousemove over the row to make the menu button visible. That function has a bug where the interval is added after `onHit` is called and the promise is resolved, leaving the interval ticking forever. Moving the `synthesizeMouseAtCenter()` after the timeout is created fixes the problem. Differential Revision: https://phabricator.services.mozilla.com/D178264
This commit is contained in:
@@ -261,14 +261,23 @@ export var UrlbarTestUtils = {
|
||||
win.gURLBar.view.resultMenu,
|
||||
"popupshown"
|
||||
);
|
||||
this._testScope?.info(`selecting the result at index ${resultIndex}`);
|
||||
while (win.gURLBar.view.selectedRowIndex != resultIndex) {
|
||||
this.EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
}
|
||||
if (byMouse) {
|
||||
this._testScope?.info(
|
||||
`synthesizing mousemove on row to make the menu button visible`
|
||||
);
|
||||
await this.EventUtils.promiseElementReadyForUserInput(
|
||||
menuButton.closest(".urlbarView-row"),
|
||||
win,
|
||||
this._testScope?.info
|
||||
);
|
||||
this._testScope?.info(`got mousemove, now clicking the menu button`);
|
||||
this.EventUtils.synthesizeMouseAtCenter(menuButton, {}, win);
|
||||
this._testScope?.info(`waiting for the menu popup to open via mouse`);
|
||||
} else {
|
||||
this._testScope?.info(`selecting the result at index ${resultIndex}`);
|
||||
while (win.gURLBar.view.selectedRowIndex != resultIndex) {
|
||||
this.EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
}
|
||||
if (this.getSelectedElement(win) != menuButton) {
|
||||
this.EventUtils.synthesizeKey("KEY_Tab", {}, win);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user