From 35818794812ad19e809ab9e37f8523fbb343c400 Mon Sep 17 00:00:00 2001 From: alwu Date: Fri, 15 May 2020 02:51:18 +0000 Subject: [PATCH] Bug 1509933 - part3 : use the new pref in tests. r=padenot This patch will do : - replace the old pref with the new pref The advantage of doing so : - to ensure those tests can still use the correct blocking autoplay policy Differential Revision: https://phabricator.services.mozilla.com/D73973 --- .../test/browser/browser_ext_autoplayInBackground.js | 2 +- dom/media/test/test_autoplay_policy.html | 4 ++-- dom/media/test/test_autoplay_policy_activation.html | 2 +- dom/media/test/test_autoplay_policy_eventdown_activation.html | 2 +- dom/media/test/test_autoplay_policy_key_blacklist.html | 2 +- dom/media/test/test_autoplay_policy_permission.html | 2 +- .../test/test_autoplay_policy_play_before_loadedmetadata.html | 2 +- dom/media/test/test_autoplay_policy_unmute_pauses.html | 2 +- .../test/test_autoplay_policy_web_audio_AudioParamStream.html | 2 +- ...est_autoplay_policy_web_audio_createMediaStreamSource.html | 2 +- ...autoplay_policy_web_audio_mediaElementAudioSourceNode.html | 2 +- ...y_web_audio_notResumePageInvokedSuspendedAudioContext.html | 2 +- .../webaudio/test/test_notAllowedToStartAudioContextGC.html | 2 +- testing/profiles/common/user.js | 2 +- toolkit/content/tests/browser/browser_autoplay_policy.js | 2 +- .../tests/browser/browser_autoplay_policy_play_twice.js | 2 +- .../browser/browser_autoplay_policy_request_permission.js | 2 +- .../tests/browser/browser_autoplay_policy_touchScroll.js | 2 +- .../tests/browser/browser_autoplay_policy_user_gestures.js | 2 +- .../browser/browser_autoplay_policy_webRTC_permission.js | 2 +- .../tests/browser/browser_autoplay_policy_web_audio.js | 2 +- .../browser/browser_autoplay_policy_web_audio_with_gum.js | 2 +- .../content/tests/browser/browser_autoplay_videoDocument.js | 2 +- toolkit/content/tests/browser/browser_delay_autoplay_media.js | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/browser/components/extensions/test/browser/browser_ext_autoplayInBackground.js b/browser/components/extensions/test/browser/browser_ext_autoplayInBackground.js index b1e82438db90..5d31706d7d32 100644 --- a/browser/components/extensions/test/browser/browser_ext_autoplayInBackground.js +++ b/browser/components/extensions/test/browser/browser_ext_autoplayInBackground.js @@ -4,7 +4,7 @@ function setup_test_preference(enableScript) { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", 1], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.allow-extension-background-pages", enableScript], ], }); diff --git a/dom/media/test/test_autoplay_policy.html b/dom/media/test/test_autoplay_policy.html index 4cb57bf5f0a0..608ec1a6ce21 100644 --- a/dom/media/test/test_autoplay_policy.html +++ b/dom/media/test/test_autoplay_policy.html @@ -15,7 +15,7 @@ let manager = new MediaTestManager; gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); window.info = function(msg, token) { SimpleTest.info(msg + ", token=" + token); @@ -78,7 +78,7 @@ function createTestArray() * Main test function for different autoplay cases without user interaction. * * When the pref "media.autoplay.default" is 1 and the pref - * "media.autoplay.enabled.user-gestures-needed" is true, we only allow + * "media.autoplay.blocking_policy" is 0, we only allow * audible media to autoplay after the website has been activated by specific * user gestures. However, inaudible media won't be restricted. * diff --git a/dom/media/test/test_autoplay_policy_activation.html b/dom/media/test/test_autoplay_policy_activation.html index cfdacdca5abf..eae266030e4e 100644 --- a/dom/media/test/test_autoplay_policy_activation.html +++ b/dom/media/test/test_autoplay_policy_activation.html @@ -15,7 +15,7 @@ // which have been activated by same-origin user gesture. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({'set': gTestPrefs}, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_eventdown_activation.html b/dom/media/test/test_autoplay_policy_eventdown_activation.html index 82b9777282af..878f996ec596 100644 --- a/dom/media/test/test_autoplay_policy_eventdown_activation.html +++ b/dom/media/test/test_autoplay_policy_eventdown_activation.html @@ -16,7 +16,7 @@ // Tests that we gesture activate on mousedown and keydown. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_key_blacklist.html b/dom/media/test/test_autoplay_policy_key_blacklist.html index 967effbebf75..a85c63713a02 100644 --- a/dom/media/test/test_autoplay_policy_key_blacklist.html +++ b/dom/media/test/test_autoplay_policy_key_blacklist.html @@ -19,7 +19,7 @@ // audible autoplay. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_permission.html b/dom/media/test/test_autoplay_policy_permission.html index 1f285ac6723f..ad9a24fcbc10 100644 --- a/dom/media/test/test_autoplay_policy_permission.html +++ b/dom/media/test/test_autoplay_policy_permission.html @@ -16,7 +16,7 @@ // Tests that origins with "autoplay-media" permission can autoplay. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_play_before_loadedmetadata.html b/dom/media/test/test_autoplay_policy_play_before_loadedmetadata.html index 7295d2734a61..b5f70be22742 100644 --- a/dom/media/test/test_autoplay_policy_play_before_loadedmetadata.html +++ b/dom/media/test/test_autoplay_policy_play_before_loadedmetadata.html @@ -20,7 +20,7 @@ // is called before the video has reached readyState >= HAVE_METADATA. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_unmute_pauses.html b/dom/media/test/test_autoplay_policy_unmute_pauses.html index 1626cc7cfd69..29ce4b801fd3 100644 --- a/dom/media/test/test_autoplay_policy_unmute_pauses.html +++ b/dom/media/test/test_autoplay_policy_unmute_pauses.html @@ -20,7 +20,7 @@ // which have been activated by same-origin user gesture. gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]); + ["media.autoplay.blocking_policy", 0]); SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { runTest(); diff --git a/dom/media/test/test_autoplay_policy_web_audio_AudioParamStream.html b/dom/media/test/test_autoplay_policy_web_audio_AudioParamStream.html index 9ae68775b3f5..27dfa5388f14 100644 --- a/dom/media/test/test_autoplay_policy_web_audio_AudioParamStream.html +++ b/dom/media/test/test_autoplay_policy_web_audio_AudioParamStream.html @@ -44,7 +44,7 @@ SimpleTest.waitForExplicitFinish(); function setupTestPreferences() { return SpecialPowers.pushPrefEnv({"set": [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-webaudio", true], ["media.autoplay.block-event.enabled", true], ]}); diff --git a/dom/media/test/test_autoplay_policy_web_audio_createMediaStreamSource.html b/dom/media/test/test_autoplay_policy_web_audio_createMediaStreamSource.html index 33efa3e5e702..5fe9aa64fc41 100644 --- a/dom/media/test/test_autoplay_policy_web_audio_createMediaStreamSource.html +++ b/dom/media/test/test_autoplay_policy_web_audio_createMediaStreamSource.html @@ -39,7 +39,7 @@ SimpleTest.waitForExplicitFinish(); function setupTestPreferences() { return SpecialPowers.pushPrefEnv({"set": [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-webaudio", true], ["media.autoplay.block-event.enabled", true], ]}); diff --git a/dom/media/test/test_autoplay_policy_web_audio_mediaElementAudioSourceNode.html b/dom/media/test/test_autoplay_policy_web_audio_mediaElementAudioSourceNode.html index 18c376638219..07d3315f383a 100644 --- a/dom/media/test/test_autoplay_policy_web_audio_mediaElementAudioSourceNode.html +++ b/dom/media/test/test_autoplay_policy_web_audio_mediaElementAudioSourceNode.html @@ -42,7 +42,7 @@ SimpleTest.waitForExplicitFinish(); function setupTestPreferences() { return SpecialPowers.pushPrefEnv({"set": [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-webaudio", true], ["media.autoplay.block-event.enabled", true], ]}); diff --git a/dom/media/test/test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html b/dom/media/test/test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html index 1c0fcb37bbf1..cbf4743dd45e 100644 --- a/dom/media/test/test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html +++ b/dom/media/test/test_autoplay_policy_web_audio_notResumePageInvokedSuspendedAudioContext.html @@ -42,7 +42,7 @@ SimpleTest.waitForExplicitFinish(); function setupTestPreferences() { return SpecialPowers.pushPrefEnv({"set": [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-webaudio", true], ["media.autoplay.block-event.enabled", true], ]}); diff --git a/dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html b/dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html index c8c352419c2f..b8715c16449a 100644 --- a/dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html +++ b/dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html @@ -26,7 +26,7 @@ SimpleTest.registerCleanupFunction(function() { }); SpecialPowers.pushPrefEnv({"set": [["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true]]}, + ["media.autoplay.blocking_policy", 0]]}, startTest); function startTest() { diff --git a/testing/profiles/common/user.js b/testing/profiles/common/user.js index 9fbe3f923a5e..d9240ec7164f 100644 --- a/testing/profiles/common/user.js +++ b/testing/profiles/common/user.js @@ -58,7 +58,7 @@ user_pref("xpinstall.signatures.required", false); user_pref("services.settings.server", "http://localhost/remote-settings-dummy/v1"); // Ensure autoplay is enabled for all platforms. user_pref("media.autoplay.default", 0); // 0=Allowed, 1=Blocked, 2=Prompt -user_pref("media.autoplay.enabled.user-gestures-needed", true); +user_pref("media.autoplay.blocking_policy", 0); user_pref("media.autoplay.ask-permission", false); user_pref("media.autoplay.block-webaudio", false); user_pref("media.allowed-to-play.enabled", true); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy.js b/toolkit/content/tests/browser/browser_autoplay_policy.js index 6d4b60501b6d..2d6542bd2125 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy.js @@ -17,7 +17,7 @@ function setupTestPreferences(isAllowedAutoplay, isAllowedMuted) { set: [ ["dom.media.autoplay.autoplay-policy-api", true], ["media.autoplay.default", autoplayDefault], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ], }); } diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_play_twice.js b/toolkit/content/tests/browser/browser_autoplay_policy_play_twice.js index 50f4a966e0cc..92e66954040c 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_play_twice.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_play_twice.js @@ -7,7 +7,7 @@ function setup_test_preference(enableUserGesture) { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", enableUserGesture], + ["media.autoplay.blocking_policy", enableUserGesture ? 0 : 1], ], }); } diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_request_permission.js b/toolkit/content/tests/browser/browser_autoplay_policy_request_permission.js index cfa856269b59..b5e28ff48478 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_request_permission.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_request_permission.js @@ -20,7 +20,7 @@ function setTestingPreferences(defaultSetting) { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", defaultValue], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-event.enabled", true], ], }); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_touchScroll.js b/toolkit/content/tests/browser/browser_autoplay_policy_touchScroll.js index 0fbd547c1fcf..ef9f32bb15f1 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_touchScroll.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_touchScroll.js @@ -77,7 +77,7 @@ add_task(async function setup_test_preference() { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ], }); }); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js index 69d2ed7995c5..0b2a70a20feb 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js @@ -65,7 +65,7 @@ function setupTestPreferences() { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-event.enabled", true], ["media.autoplay.block-webaudio", true], ["media.navigator.permission.fake", true], diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_webRTC_permission.js b/toolkit/content/tests/browser/browser_autoplay_policy_webRTC_permission.js index 8e3449f99bbd..f590c5dd3926 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_webRTC_permission.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_webRTC_permission.js @@ -15,7 +15,7 @@ add_task(() => { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-event.enabled", true], ], }); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js index 090de46c70c7..9a72665413b3 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js @@ -19,7 +19,7 @@ function setup_test_preference() { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-webaudio", true], ["media.autoplay.block-event.enabled", true], ], diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js index c6248feddc51..55480eae5c50 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js @@ -48,7 +48,7 @@ function setupTestPreferences() { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ["media.autoplay.block-event.enabled", true], ["media.autoplay.block-webaudio", true], ["media.navigator.permission.fake", true], diff --git a/toolkit/content/tests/browser/browser_autoplay_videoDocument.js b/toolkit/content/tests/browser/browser_autoplay_videoDocument.js index ac5ca5d50ba8..12cf35e9f919 100644 --- a/toolkit/content/tests/browser/browser_autoplay_videoDocument.js +++ b/toolkit/content/tests/browser/browser_autoplay_videoDocument.js @@ -7,7 +7,7 @@ function setup_test_preference() { return SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ], }); } diff --git a/toolkit/content/tests/browser/browser_delay_autoplay_media.js b/toolkit/content/tests/browser/browser_delay_autoplay_media.js index 675d7382b7bd..acaf4ed16a81 100644 --- a/toolkit/content/tests/browser/browser_delay_autoplay_media.js +++ b/toolkit/content/tests/browser/browser_delay_autoplay_media.js @@ -111,7 +111,7 @@ add_task(async function resume_delayed_media_when_enable_blocking_autoplay() { await SpecialPowers.pushPrefEnv({ set: [ ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], - ["media.autoplay.enabled.user-gestures-needed", true], + ["media.autoplay.blocking_policy", 0], ], });