Permission prompts replaced by a new prompt with the same ID leave the original request dangling
Categories
(Firefox :: Site Permissions, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox152 | --- | fixed |
People
(Reporter: emz, Assigned: emz)
References
()
Details
(Keywords: ai-involved)
Attachments
(4 external files)
When PermissionUI.sys.mjs's PermissionPrompt.prompt() is called a second time for the same permission on the same browser — e.g. a page calling navigator.geolocation.getCurrentPosition() twice in quick succession — PopupNotifications.show() silently replaces the existing popup. The old notification's eventCallback fires "removed" but without the isCancel flag, so PermissionUI's if (isCancel) this.cancel() gate skips the cancel and the underlying nsIContentPermissionRequest is never answered. The content-side promise dangles forever.
The same dangling pattern affects tab close, navigation away, and docshell swap paths inside PopupNotifications.sys.mjs — those also fire "removed" without passing the flag. WebRTC prompts (WebRTCParent.sys.mjs) have the same gate and leak in the same situations.
Steps to reproduce:
- Load a page that calls
navigator.geolocation.getCurrentPosition(ok, err)twice synchronously. For example https://playground.emz.run/repeated-permission-request/ - Observe two prompts are requested; the first is immediately replaced.
- The first call's ok/err callbacks are never invoked.
Expected: the first request receives PERMISSION_DENIED so the content-side promise settles.
Eventually we might want to do a chaining approach like suggested in Bug 2033443 to resolve this, but for now we should cancel old requests that no longer have an associated notification (prompt) for consistency. This also means websites know that their request got rejected rather than leaving them hanging indefinitely.
Actual: the first request dangles indefinitely.
| Assignee | ||
Updated•6 months ago
|
| Assignee | ||
Comment 1•6 months ago
|
||
PopupNotifications fires "removed" from several external-removal paths
(tab close, navigation, same-id replacement, refused docshell swap,
removeOnDismissal) without setting the flag that signals "no user
response," leaving permission prompts' underlying
nsIContentPermissionRequest dangling. Pass withoutUserResponse=true on
those paths; action-callback paths keep the default false because
allow()/cancel() already ran.
The flag is also renamed from isCancel (permission-subsystem vocabulary)
to withoutUserResponse, describing the signal from PopupNotifications'
own POV. PermissionUI, WebRTCParent, and the external callers that pass
the flag explicitly are updated to match.
Updated•6 months ago
|
| Assignee | ||
Comment 2•6 months ago
|
||
| Assignee | ||
Comment 3•6 months ago
|
||
| Assignee | ||
Comment 4•6 months ago
|
||
ShowPrompt already calls nsContentPermissionUtils::AskPermission in its
Pending branch, but Start then fell through to call AskPermission a
second time. A single persist() pushed two notifications with the same
id through PopupNotifications for the same underlying request.
The duplicate used to be silently absorbed by PopupNotifications.show's
same-id replacement. After the PopupNotifications.sys.mjs refactor
earlier in this stack, that replacement now fires "removed" with
withoutUserResponse=true, which PermissionUI treats as a signal to
cancel the request. Since both notifications shared the same request,
cancel() resolved the persist() promise before the user's Allow click
could run, breaking browser_permissionsPromptAllow.js.
Check permission delegation directly and call AskPermission once.
CheckPermissionDelegate preserves the delegation guard that used to
live inside ShowPrompt. The Android workaround branch is no longer
needed because both platforms now take the single-ask path.
Comment 6•6 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/1cfd12d2eb32
https://hg.mozilla.org/mozilla-central/rev/041ffb13c6bb
https://hg.mozilla.org/mozilla-central/rev/b1aea331ad76
https://hg.mozilla.org/mozilla-central/rev/823adb8a187f
Description
•