Bug 1858758 - [remote] Focus a window if it has no focus when selecting a tab. r=webdriver-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D195099
This commit is contained in:
Alexandra Borovova 2023-12-05 09:15:58 +00:00
Родитель 7ba6eea8a0
Коммит a8e3936c65
1 изменённых файлов: 12 добавлений и 2 удалений

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

@ -406,7 +406,7 @@ class TabManagerClass {
* @returns {Promise}
* Promise that resolves when the given tab has been selected.
*/
selectTab(tab) {
async selectTab(tab) {
if (!tab) {
return Promise.resolve();
}
@ -420,7 +420,17 @@ class TabManagerClass {
const selected = new lazy.EventPromise(ownerWindow, "TabSelect");
tabBrowser.selectedTab = tab;
return selected;
await selected;
// Sometimes at that point window is not focused.
if (Services.focus.activeWindow != ownerWindow) {
const activated = new lazy.EventPromise(ownerWindow, "activate");
ownerWindow.focus();
return activated;
}
return Promise.resolve();
}
supportsTabs() {