Fix context menu bouncing in Edge browse mode (#15316)
Fixes #15309
Summary of the issue:
In Edge browse mode, when opening the context menu, NVDA many times goes back to browse mode.
Description of user facing changes
NVDA will no correctly focus the context menu opened from Edge browse mode.
Description of development approach
The issue behind this is as follows. Take a link as example:
Disabling the option Automatically set system focus to focusable elements ensures that an object only gets focus when strictly necessary. This is the case when opening the context menu, because otherwise, the context menu would open for the wrong object.
When opening the context menu on the link, NVDA calls script_passThrough
script_passThrough calls setFocus on the link's object and sends the gesture.
Two focus events are fired, one for the link in the document and one for the context menu
NVDA first processes the context menu event and after that, the link object event
Focus bounces from the context menu back to the link.
There is a very trivial fix for this. With calling api.processPendingEvents, we ensure that NVDA first processes the event generated by setFocus before executing the gesture.