Skip to content

Commit 7c05b14

Browse files
committed
fix browser.windows undef error for mobile firefox
1 parent fa82942 commit 7c05b14

File tree

1 file changed

+12
-2
lines changed
  • Extension/src/common/api/extension

1 file changed

+12
-2
lines changed

Extension/src/common/api/extension/tabs.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import browser, { type Tabs } from 'webextension-polyfill';
1919

2020
import { Prefs } from '../../../background/prefs';
21+
import { UserAgent } from '../../user-agent';
2122

2223
/**
2324
* Helper class for browser.tabs API.
@@ -45,9 +46,18 @@ export class TabsApi {
4546
const { id, windowId } = tab;
4647

4748
await browser.tabs.update(id, { active: true });
48-
if (windowId) {
49-
await browser.windows.update(windowId, { focused: true });
49+
50+
// browser.windows is not available in Firefox for Android
51+
// TODO: check how it works in Edge on Android
52+
if (UserAgent.isFirefox && (await UserAgent.getIsAndroid())) {
53+
return;
54+
}
55+
56+
if (!windowId) {
57+
return;
5058
}
59+
60+
await browser.windows.update(windowId, { focused: true });
5161
}
5262

5363
/**

0 commit comments

Comments
 (0)