commit 6e9fb8e98296a6df25135d70c1035e97cc1219ac
parent ebc06b39579abd863a5c84592e6e690723f2941b
Author: az <azebrowski@mozilla.com>
Date: Mon, 17 Nov 2025 15:38:33 +0000
Bug 1996123 - Permit consecutive Android autoplay permission grants/denials of the same type. r=media-playback-reviewers,aosmond,alwu
Differential Revision: https://phabricator.services.mozilla.com/D271415
Diffstat:
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/dom/media/autoplay/GVAutoplayPermissionRequest.cpp b/dom/media/autoplay/GVAutoplayPermissionRequest.cpp
@@ -132,13 +132,16 @@ void GVAutoplayPermissionRequest::SetRequestStatus(RStatus aStatus) {
NS_IMETHODIMP
GVAutoplayPermissionRequest::Cancel() {
MOZ_ASSERT(mContext, "Do not call 'Cancel()' twice!");
- // As the process of replying of the request is an async task, the status
- // might have be reset at the time we get the result from parent process.
- // Ex. if the page got closed or naviagated immediately after user replied to
+ // As the process of replying to the request is an async task, the status
+ // might have been reset at the time we get the result from parent process.
+ // Ex. if the page got closed or navigated immediately after user replied to
// the request. Therefore, the status should be either `pending` or `unknown`.
+ // Additionally, we tolerate `canceled` if the request was already canceled.
+ // See Bug 1996123 for details on the multiple cancel.
const RStatus status = GetRequestStatus(mContext, mType);
REQUEST_LOG("Cancel, current status=%s", EnumValueToString(status));
- MOZ_ASSERT(status == RStatus::ePENDING || status == RStatus::eUNKNOWN);
+ MOZ_ASSERT(status == RStatus::ePENDING || status == RStatus::eDENIED ||
+ status == RStatus::eUNKNOWN);
if ((status == RStatus::ePENDING) && !mContext->IsDiscarded()) {
SetRequestStatus(RStatus::eDENIED);
}
@@ -149,13 +152,16 @@ GVAutoplayPermissionRequest::Cancel() {
NS_IMETHODIMP
GVAutoplayPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
MOZ_ASSERT(mContext, "Do not call 'Allow()' twice!");
- // As the process of replying of the request is an async task, the status
- // might have be reset at the time we get the result from parent process.
- // Ex. if the page got closed or naviagated immediately after user replied to
+ // As the process of replying to the request is an async task, the status
+ // might have been reset at the time we get the result from parent process.
+ // Ex. if the page got closed or navigated immediately after user replied to
// the request. Therefore, the status should be either `pending` or `unknown`.
+ // Additionally, we tolerate `allowed` if the request was already allowed.
+ // See Bug 1996123 for details on the multiple allow.
const RStatus status = GetRequestStatus(mContext, mType);
REQUEST_LOG("Allow, current status=%s", EnumValueToString(status));
- MOZ_ASSERT(status == RStatus::ePENDING || status == RStatus::eUNKNOWN);
+ MOZ_ASSERT(status == RStatus::ePENDING || status == RStatus::eALLOWED ||
+ status == RStatus::eUNKNOWN);
if (status == RStatus::ePENDING) {
SetRequestStatus(RStatus::eALLOWED);
// Permission grant may arrive late and elements may be suspended.
@@ -166,7 +172,6 @@ GVAutoplayPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
/* no extra string data */ nullptr);
}
}
-
mContext = nullptr;
return NS_OK;
}