Bug 1476853 - Don't block WebAudio autoplay by default. r?padenot
Pending figuring out how we want to block autoplay of WebAudio content, we
should just not block it by default for the initial release of block autoplay,
and follow up once we've figured out how to not break the web.
MozReview-Commit-ID: ClfdrHcugLs
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -124,16 +124,20 @@ AutoplayPolicy::IsAllowedToPlay(const HT
}
return autoplayDefault;
}
/* static */ bool
AutoplayPolicy::IsAudioContextAllowedToPlay(NotNull<AudioContext*> aContext)
{
+ if (!Preferences::GetBool("media.autoplay.block-webaudio", false)) {
+ return true;
+ }
+
if (DefaultAutoplayBehaviour() == nsIAutoplay::ALLOWED) {
return true;
}
if (!Preferences::GetBool("media.autoplay.enabled.user-gestures-needed", false)) {
return true;
}
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -562,16 +562,19 @@ pref("media.recorder.audio_node.enabled"
// Whether MediaRecorder's video encoder should allow dropping frames in order
// to keep up under load. Useful for tests but beware of memory consumption!
pref("media.recorder.video.frame_drops", true);
// Whether to autostart a media element with an |autoplay| attribute.
// ALLOWED=0, BLOCKED=1, PROMPT=2, defined in dom/media/Autoplay.idl
pref("media.autoplay.default", 0);
+// By default, don't block WebAudio from playing automatically.
+pref("media.autoplay.block-webaudio", false);
+
// If "media.autoplay.default" is not ALLOWED, and this pref is true,
// then audible media would only be allowed to autoplay after website has
// been activated by specific user gestures, but non-audible
// media won't be restricted.
#ifdef NIGHTLY_BUILD
pref("media.autoplay.enabled.user-gestures-needed", false);
#endif
--- a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js
+++ b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js
@@ -13,16 +13,17 @@ var UserGestureTests = [
{type: UserGestures.MOUSE_MOVE, isActivationGesture: false},
{type: UserGestures.KEYBOARD_PRESS, isActivationGesture: true}
];
function setup_test_preference() {
return SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
+ ["media.autoplay.block-webaudio", true],
["media.navigator.permission.fake", true]
]});
}
function simulateUserGesture(gesture, targetBrowser) {
info(`- simulate ${gesture.type} event -`);
switch (gesture.type) {
case UserGestures.MOUSE_CLICK: