Open Bug 1817809 Opened 3 years ago Updated 1 month ago

Support action.openPopup on Fenix (implement onOpenPopup override of ActionDelegate in A-C)

Categories

(Firefox for Android :: WebExtensions, enhancement, P3)

All
Android
enhancement

Tracking

()

People

(Reporter: robwu, Unassigned)

References

Details

(Whiteboard: [addons-jira])

Bug 1530402 introduced support for the browser/page action extension APIs. They have mostly been hooked up. One of the methods, the openPopup method has not correctly been hooked up in A-C, despite the method being supported in GeckoView (unit test: ExtensionActionTest.kt), and supported in TestRunnerActivity (source) and GVE (source).

This report shows the STR and provides guidance on supporting the functionality in A-C / Fenix.

Steps to reproduce

This can manually be confirmed on current Firefox for Android builds:

  1. Install uBlock Origin (that has a browserAction popup).
  2. Attach a debugger (enabling ADB debugging, enabling remote debugging in the Firefox app and then via about:debugging on desktop)
  3. Open any tab (e.g. example.com) to launch the Gecko process.
  4. Ensure that we can call browser.browserAction.openPopup. This currently requires a user gesture (until bug 1799344 removes that requirement). There are three ways to meet this requirement:
  • Set the extensions.openPopupWithoutUserGesture.enabled preference to true,
  • Or by opening an extension page, registering a click event listener and call the openPopup method from the click handler,
  • Inspect the extension and call browser.tabs.create({ url: browser.runtime.getURL("manifest.json") }) to open a new extension tab.
  • Inspect that tab in the devtools, and register the listener: document.body.onclick = () => { browser.browserAction.openPopup(); };.
  • Interact with the browser manually by tapping in the content area of the tab.
  1. Once you have enabled the openPopup API (step 4), open the popup by calling browser.browserAction.openPopup(); (e.g. via the devtools).

Expected behavior

  • The extension popup opens.

Actual behavior

  • Nothing happens.

Implementation details

To support it on Fenix:

Additional notes:

  • It would be really nice to be able to open the popup for arbitrary "windows" (tabs / GeckoSession), and not to assume it to be whatever the currently active tab is. That should be fixed along with bug 1817772 (see also: https://bugzilla.mozilla.org/show_bug.cgi?id=1795956#c1 ).
  • Not a must-have, but if possible, it would be nice to notify GeckoView/Gecko when the popup has finally been opened (to support bug 1811071).

This would be a good-first-bug for WebExtension engineers who are looking to contribute to Android-Components / Fenix.

Not a must-have, but if possible, it would be nice to notify GeckoView/Gecko when the popup has finally been opened (to support bug 1811071).

See Also: → 1811071
Severity: -- → N/A
Priority: -- → P3
Duplicate of this bug: 1952010

The code has moved;

Here is the relevant code today:

If someone is interested in contributing a patch.

$ ./mach bootstrap
...
Choose option 3:
  3. GeckoView/Firefox for Android Artifact Mode

Then create a .mozconfig-android file with the output suggested by ./mach bootstrap .

To launch the browser for manual testing, build the application and run as follows (in an Android emulator):

MOZCONFIG=.mozconfig-android ./mach build
MOZCONFIG=.mozconfig-android ./mach run --app=fenix

To run the unit test:

MOZCONFIG=.mozconfig-android ./mach test mobile/android/android-components/components/browser/engine-gecko/src/test/java/mozilla/components/browser/engine/gecko/webextension/GeckoWebExtensionTest.kt

(note: if you cannot see the output, see https://bugzilla.mozilla.org/show_bug.cgi?id=1950183#c2).

See Also: → 2011516

Note: when working on this bug, double check the behavior for PWA and custom tabs.

Incidentally, I recently observed that a browser.tabs.create() call from an extension's background page on startup to trigger the opening of a tab. It is possible that there are more issues, resulting in the need to have a separate bug tracking extension interaction while in a custom tab, without blocking this current bug.

See Also: → 2015895
See Also: → 2016283
You need to log in before you can comment on or make changes to this bug.