Support action.openPopup on Fenix (implement onOpenPopup override of ActionDelegate in A-C)
Categories
(Fenix :: WebExtensions, enhancement)
Tracking
(Not tracked)
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:
- Install uBlock Origin (that has a browserAction popup).
- Attach a debugger (enabling ADB debugging, enabling remote debugging in the Firefox app and then via about:debugging on desktop)
- Open any tab (e.g. example.com) to launch the Gecko process.
- 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,- via the instructions at https://firefox-source-docs.mozilla.org/mobile/android/geckoview/consumer/automation.html
- or by inspecting the main process via
about:debugging
(from step 2) and runningServices.prefs.setBoolPref("extensions.openPopupWithoutUserGesture.enabled", true)
(if this is your main profile, revert this when you're done by runningServices.prefs.clearUserPref("extensions.openPopupWithoutUserGesture.enabled")
- Or by opening an extension page, registering a
click
event listener and call theopenPopup
method from theclick
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.
- Once you have enabled the
openPopup
API (step 4), open the popup by callingbrowser.browserAction.openPopup();
(e.g. via the devtools).
Expected behavior
- The extension popup opens.
Actual behavior
- Nothing happens.
Implementation details
To support it on Fenix:
- A-C: Add an
onOpenPopup
override at https://github.com/mozilla-mobile/firefox-android/blob/9de5ab8cc098674aad5190ce8b00ae6be65e9bd0/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/webextension/GeckoWebExtension.kt#L177-L204- The implementation should show the popup if it was not visible, and be no-op if it was visible (or reject the call with an error; in this case GeckoView would need to be updated to handle the error).
- Along with the changes in A-C, whatever that's needed to actually hook it up in Fenix.
- Add a unit test at https://github.com/mozilla-mobile/firefox-android/blob/9de5ab8cc098674aad5190ce8b00ae6be65e9bd0/android-components/components/browser/engine-gecko/src/test/java/mozilla/components/browser/engine/gecko/webextension/GeckoWebExtensionTest.kt#L259
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).
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
This would be a good-first-bug for WebExtension engineers who are looking to contribute to Android-Components / Fenix.
Reporter | ||
Comment 2•2 years ago
|
||
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).
Description
•