Skip to content

Commit

Permalink
Bug 1513039 - part10 : remove nsIAutoplay.PROMPT r=daleharvey,cpearce
Browse files Browse the repository at this point in the history
Depends on D14334

Differential Revision: https://phabricator.services.mozilla.com/D14335

--HG--
extra : moz-landing-system : lando
  • Loading branch information
alastor0325 committed Jan 7, 2019
1 parent 99419e9 commit edbf43d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,11 @@ pref("media.autoplay.enabled.user-gestures-needed", true);
// Allow asking for permission to autoplay to appear in UI.
pref("media.autoplay.ask-permission", false);
// Set Firefox to block autoplay, asking for permission by default.
pref("media.autoplay.default", 1); // 0=Allowed, 1=Blocked, 2=Prompt
pref("media.autoplay.default", 1); // 0=Allowed, 1=Blocked
// Block WebAudio from playing automatically.
pref("media.autoplay.block-webaudio", true);
#else
pref("media.autoplay.default", 0); // 0=Allowed, 1=Blocked, 2=Prompt
pref("media.autoplay.default", 0); // 0=Allowed, 1=Blocked
pref("media.autoplay.enabled.user-gestures-needed", false);
pref("media.autoplay.ask-permission", false);
pref("media.autoplay.block-webaudio", false);
Expand Down
6 changes: 3 additions & 3 deletions dom/media/AutoplayPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
static uint32_t DefaultAutoplayBehaviour() {
int prefValue =
Preferences::GetInt("media.autoplay.default", nsIAutoplay::ALLOWED);
if (prefValue < nsIAutoplay::ALLOWED || prefValue > nsIAutoplay::PROMPT) {
// Invalid pref values are just converted to ALLOWED.
return nsIAutoplay::ALLOWED;
if (prefValue < nsIAutoplay::ALLOWED || prefValue > nsIAutoplay::BLOCKED) {
// Invalid pref values are just converted to BLOCKED.
return nsIAutoplay::BLOCKED;
}
return prefValue;
}
Expand Down
1 change: 0 additions & 1 deletion dom/media/nsIAutoplay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ interface nsIAutoplay : nsISupports
*/
const uint32_t ALLOWED = 0;
const uint32_t BLOCKED = 1;
const uint32_t PROMPT = 2;
};
4 changes: 2 additions & 2 deletions mobile/android/app/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ pref("media.autoplay.enabled.user-gestures-needed", true);
// UI/prompting for permission isn't implemented for Fennec, so disable.
pref("media.autoplay.ask-permission", false);
// Set Fennec to block autoplay by default.
pref("media.autoplay.default", 1); // 0=Allowed, 1=Blocked, 2=Prompt
pref("media.autoplay.default", 1); // 0=Allowed, 1=Blocked
#else
pref("media.autoplay.default", 0); // 0=Allowed, 1=Blocked, 2=Prompt
pref("media.autoplay.default", 0); // 0=Allowed, 1=Blocked
pref("media.autoplay.enabled.user-gestures-needed", false);
pref("media.autoplay.ask-permission", false);
#endif
Expand Down
2 changes: 1 addition & 1 deletion modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pref("media.recorder.audio_node.enabled", false);
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
// ALLOWED=0, BLOCKED=1, defined in dom/media/Autoplay.idl
pref("media.autoplay.default", 0);

// By default, don't block WebAudio from playing automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ async function synthesizeTouchScroll(target, browser) {

add_task(async function setup_test_preference() {
return SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.PROMPT],
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
["media.autoplay.ask-permission", true],
]});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const VIDEO_PAGE = "https://example.com/browser/toolkit/content/tests/browser/fi

add_task(() => {
return SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.PROMPT],
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
["media.autoplay.block-event.enabled", true],
]});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const PAGE = "https://example.com/browser/toolkit/content/tests/browser/audio.og

function setup_test_preference() {
return SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.PROMPT],
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
["media.autoplay.ask-permission", true],
]});
Expand Down
9 changes: 4 additions & 5 deletions toolkit/content/tests/browser/browser_block_autoplay_media.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ add_task(async function block_autoplay_media() {
await check_audio_suspended(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK);


// Test 4: Disable autoplay, enable asking for permission, and verify
// that when a tab is opened in the background and has had its playback
// start delayed, resuming via the audio tab indicator overrides the
// autoplay blocking logic.
// Test 4: Disable autoplay and verify that when a tab is opened in the
// background and has had its playback start delayed, resuming via the audio
// tab indicator overrides the autoplay blocking logic.
//
// Clicking "play" on the audio tab indicator should always start playback
// in that tab, even if it's in an autoplay-blocked origin.
Expand All @@ -84,7 +83,7 @@ add_task(async function block_autoplay_media() {
// a new document being loaded into the tab; the new document should have
// to satisfy the autoplay requirements on its own.
await SpecialPowers.pushPrefEnv({"set": [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.PROMPT],
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.enabled.user-gestures-needed", true],
["media.autoplay.ask-permission", true],
]});
Expand Down

0 comments on commit edbf43d

Please sign in to comment.