Closed Bug 1799344 Opened 3 years ago Closed 1 month ago

Enable browserAction.openPopup without user interaction on all channels (Remove `extensions.openPopupWithoutUserGesture.enabled` preference)

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(firefox149 fixed)

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: oliver, Assigned: robwu)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, Whiteboard: [addons-jira])

Attachments

(2 files)

In https://phabricator.services.mozilla.com/D139796, I updated the browserAction.openPopup API to remove the user gesture requirement. We initially put this behind a preference which by default is only set to true on Nightly. This allowed us to land the patch earlier before being sure of some more specific implementation details, such as if we will put this behind a permission.

This bug is to track removing that preference and enabling the change by default.

Depends on: 1799345
Depends on: 1799347
Depends on: 1798334
Duplicate of this bug: 1799360
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → 1755763
Severity: -- → N/A
Priority: -- → P5
Depends on: 1811071
Blocks: 1392624
See Also: → 1817809
Whiteboard: [addons-jira]

This should be fixed for better Manifest V3 (but also not-persistent V2) compatibility.
Why?
Not persistent background scripts (where for example browser.contextMenus.onClicked.addListener lives) may need to load user options before calling browser.browserAction.openPopup, which won't work, due to asynchronous nature of storage.
(for example, user may want the context menu click to open new window, new tab, popup, or inject modal)

Note that Chrome 127 will finally have it implemented:
https://github.com/w3c/webextensions/issues/160#issuecomment-2147143055

It would be great help for devs to have this in upcoming Firefox ESR 128.

:robwu I am not sure where to put this so I'll start here. I've noticed that https://addons.mozilla.org/en-US/firefox/addon/icloud-passwords/ doesn't work well with this pref set to true, the UI is unusable as soon as we open the popup from within the extensions panel. It works relatively well when the extension is pinned to the nav-bar, though.

Flags: needinfo?(rob)

Hi! Curious about the status of this. I have a similar use case to juraj above. My intended behavior is to click an element in a popup window, close it in the on click handler and trigger the extension popup to open with browser.browserAction.openPopup. Having initially tried it, it seems that the browser would attempt to call browser.browserAction.openPopup from within the popup window context which leads to an error. Instead, I send a message with browser.runtime.sendMessage to send a message to the background script to trigger the browser.browserAction.openPopup call after a 100ms timeout. This works wonderfully in chrome, but I get a user gesture token error in firefox. The token seems to be lost in the message listener with or without the timeout. It would be nice if this requirement was removed or if someone can suggest a workaround to maintain cross-browser functionality.

Type: task → enhancement
Flags: needinfo?(rob)
Summary: Remove `extensions.openPopupWithoutUserGesture.enabled` preference → Enable browserAction.openPopup without user interaction on all channels (Remove `extensions.openPopupWithoutUserGesture.enabled` preference)

(In reply to William Durand [:willdurand] from comment #3)

:robwu I am not sure where to put this so I'll start here. I've noticed that https://addons.mozilla.org/en-US/firefox/addon/icloud-passwords/ doesn't work well with this pref set to true, the UI is unusable as soon as we open the popup from within the extensions panel. It works relatively well when the extension is pinned to the nav-bar, though.

This is tracked by bug 1799347.

Depends on: 1967196
Depends on: 2011516

Ahead of enabling this by default, I checked the current cross-browser behaviors and shared the comparison with Chrome 143, Firefox 148 (with pref enabled) and the desired behavior at https://github.com/w3c/webextensions/issues/160#issuecomment-3774666519

The current behaviors in-tree are mostly similar to the desired behaviors. There are two main areas of behavior that needs to be updated:

  • bug 1799347 - explicitly reject when the popup (or something else) is already open. There is some validation, but from testing I can still pop up a new popup when another extension popup is showing.
  • bug 2011516 - reject openPopup() for non-foreground windows.

After adding these explicit checks, we are ready to enable the feature by default on desktop.
For Android, bug 1817809 needs to be fixed.

The bugs not explicitly listed here can be worked on independently, with the intent to land them in the 149 cycle.

Assignee: nobody → rob
Status: NEW → ASSIGNED
See Also: → 2013250
Pushed by amarc@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2fc080373006 https://hg.mozilla.org/integration/autoland/rev/2e2856dc7d2a Revert "Bug 1799344 - Remove user gesture restriction from action.openPopup r=rpl" for causing multiple mochitest failures

Backed out for causing mochitest fails

Flags: needinfo?(rob)

The dependency was inadvertently missing from the patch stack. I'm going to reland with https://bugzilla.mozilla.org/show_bug.cgi?id=2011516#c4 from bug 2011516 included.

Flags: needinfo?(rob)
Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c1b64e6ecf86 https://hg.mozilla.org/integration/autoland/rev/f98e369bc86f Revert "Bug 1799344, Bug 2011516, Bug 1799347 - Remove user gesture restriction from action.openPopup r=rpl" for cauisng failures at test_ext_action_openPopup_multiple.html.
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Flags: needinfo?(rob)

The action.openPopup and browserAction.openPopup APIs are now available on non-Nightly channels from version 149, without requiring the user to set a pref. This should be documented in release notes, BCD, maybe mdn/content.

comment 6 has a bit more context on behaviors.

Keywords: dev-doc-needed
Depends on: 2022281
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: