tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 720bc69d6efaf36bd3e6f49d56a946cd5905e18a
parent a55f7b5f9bd505ae438c82c5faae7ac0c6451447
Author: az <azebrowski@mozilla.com>
Date:   Fri, 14 Nov 2025 02:40:08 +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:
Mdom/media/autoplay/GVAutoplayPermissionRequest.cpp | 23++++++++++++++---------
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 || 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; }