Bug 2040387 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

### Steps to reproduce
1. Install any extension on Fenix, e.g. uBlock Origin.
2. Use `about:debugging` on desktop to inspect the app.
3. Inspect the extension and run `browser.tabs.create({ active: false });`

### Expected behavior

Should open a tab in the background (this is intentionally just a blank tab, not the tab that you see when you use the UI to open a new tab - bug 1782389).

### Actual behavior

Opens a tab in the foreground.

### Device information

* Firefox version: 151
* Android device model:
* Android OS version:

### Any additional information?

The `active` flag propagates all the way from Gecko, through GeckoView to A-C, but then hits a hurdle in [`openTab` in WebExtensionSupport.kt`](https://searchfox.org/firefox-main/rev/8b3456fa29ad35f58da4cc0a1d182e039124ba5d/mobile/android/android-components/components/support/webextensions/src/main/java/mozilla/components/support/webextensions/WebExtensionSupport.kt#530-535). When `onNewTabOverride` is set, it is called, and then `onSelectTabOverride` is called if needed (if `selected` is true, which takes its value from the `active` flag we initially passed).

But the `onNewTabOverride` does not receive the `selected` flag. In fact, its implementation unconditionally passed `selectTab = true` when it calls `tabsUseCases.addTab`: https://searchfox.org/firefox-main/rev/8b3456fa29ad35f58da4cc0a1d182e039124ba5d/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt#839-846

Other `onNewTabOverrides` implementations in the code base have a similar problem.

I think that the bug could be fixed by forwarding the `selectTab` flag as needed.
### Steps to reproduce
1. Install any extension on Fenix, e.g. uBlock Origin.
2. Use `about:debugging` on desktop to inspect the app.
3. Inspect the extension and run `browser.tabs.create({ active: false });`

### Expected behavior

Should open a tab in the background (this is intentionally just a blank tab, not the tab that you see when you use the UI to open a new tab - bug 1782389).

### Actual behavior

Opens a tab in the foreground.

### Device information

* Firefox version: 151
* Android device model:
* Android OS version:

### Any additional information?

The `active` flag propagates all the way from Gecko, through GeckoView to A-C, but then hits a hurdle in [`openTab` in WebExtensionSupport.kt](https://searchfox.org/firefox-main/rev/8b3456fa29ad35f58da4cc0a1d182e039124ba5d/mobile/android/android-components/components/support/webextensions/src/main/java/mozilla/components/support/webextensions/WebExtensionSupport.kt#530-535). When `onNewTabOverride` is set, it is called, and then `onSelectTabOverride` is called if needed (if `selected` is true, which takes its value from the `active` flag we initially passed).

But the `onNewTabOverride` does not receive the `selected` flag. In fact, its implementation unconditionally passed `selectTab = true` when it calls `tabsUseCases.addTab`: https://searchfox.org/firefox-main/rev/8b3456fa29ad35f58da4cc0a1d182e039124ba5d/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt#839-846

Other `onNewTabOverrides` implementations in the code base have a similar problem.

I think that the bug could be fixed by forwarding the `selectTab` flag as needed.

Back to Bug 2040387 Comment 0