Bug 1472580 - Gesture activate documents which are played via the tab audio indicator. r=mconley
(This patch was first presented for review in
bug 1463919, I've split it off
into its own bug here).
If the user opens a tab in the background, and that tab tries to play media,
we'll delay playing that media until the tab is brought to the foreground.
But the user can explicitly start playback of such delayed media by clicking
the "play" icon we show in the tab indicator. Then if autoplay is disabled,
we'll block the play (unless the origin is whitelisted). This is bad, as the
user has clearly indicated intent to play media in this tab.
So this patch "gesture activates" the root content document when the tab audio
indicator play button is pressed. This means the block autoplay logic will
behave as if there's been a user gesture in the tab (mouse click or keypress),
and not block the play. Gesture activation state is per document, so it does
not persist across document loads.
MozReview-Commit-ID: 3pgrADRrJqt
***
fix
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -521,16 +521,21 @@ var AudioPlaybackListener = {
break;
case "mediaControlPaused":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
break;
case "mediaControlStopped":
utils.mediaSuspend = suspendTypes.SUSPENDED_STOP_DISPOSABLE;
break;
case "resumeMedia":
+ // User has clicked the tab audio indicator to play a delayed
+ // media. That's clear user intent to play, so gesture activate
+ // the content document tree so that the block-autoplay logic
+ // allows the media to autoplay.
+ content.document.notifyUserGestureActivation();
utils.mediaSuspend = suspendTypes.NONE_SUSPENDED;
break;
default:
dump("Error : wrong media control msg!\n");
break;
}
},