Bug 1814985 - part1 : remove experimental API 'document.autoplayPolicy'. r=media-playback-reviewers,emilio,padenot

Differential Revision: https://phabricator.services.mozilla.com/D168856
This commit is contained in:
alwu 2023-02-06 18:09:59 +00:00
Родитель f9f77bd25c
Коммит 4b66bff559
6 изменённых файлов: 0 добавлений и 102 удалений

Просмотреть файл

@ -22,7 +22,6 @@
#include <limits>
#include <type_traits>
#include "Attr.h"
#include "AutoplayPolicy.h"
#include "ErrorList.h"
#include "ExpandedPrincipal.h"
#include "MainThreadUtils.h"
@ -16227,10 +16226,6 @@ void Document::SetDocTreeHadMedia() {
}
}
DocumentAutoplayPolicy Document::AutoplayPolicy() const {
return media::AutoplayPolicy::IsAllowedToPlay(*this);
}
void Document::MaybeAllowStorageForOpenerAfterUserInteraction() {
if (!CookieJarSettings()->GetRejectThirdPartyContexts()) {
return;

Просмотреть файл

@ -3695,10 +3695,6 @@ class Document : public nsINode,
bool UserHasInteracted() { return mUserHasInteracted; }
void ResetUserInteractionTimer();
// This method would return current autoplay policy, it would be "allowed"
// , "allowed-muted" or "disallowed".
DocumentAutoplayPolicy AutoplayPolicy() const;
// This should be called when this document receives events which are likely
// to be user interaction with the document, rather than the byproduct of
// interaction with the browser (i.e. a keypress to scroll the view port,

Просмотреть файл

@ -11,7 +11,6 @@ support-files =
file_video.html
head.js
[browser_autoplay_policy.js]
[browser_autoplay_policy_detection_global_sticky.js]
[browser_autoplay_policy_detection_global_and_site_sticky.js]
[browser_autoplay_policy_play_twice.js]

Просмотреть файл

@ -1,78 +0,0 @@
/**
* This test is used to ensure we can get the correct document's autoplay policy
* under different situations.
* Spec discussion : https://github.com/WICG/autoplay/issues/1
*/
const PAGE = GetTestWebBasedURL("file_empty.html");
function setupTestPreferences(isAllowedAutoplay, isAllowedMuted) {
let autoplayDefault = SpecialPowers.Ci.nsIAutoplay.ALLOWED;
if (!isAllowedAutoplay) {
autoplayDefault = isAllowedMuted
? SpecialPowers.Ci.nsIAutoplay.BLOCKED
: SpecialPowers.Ci.nsIAutoplay.BLOCKED_ALL;
}
return SpecialPowers.pushPrefEnv({
set: [
["dom.media.autoplay.autoplay-policy-api", true],
["media.autoplay.default", autoplayDefault],
["media.autoplay.blocking_policy", 0],
],
});
}
async function checkAutoplayPolicy(expectedAutoplayPolicy) {
is(
content.document.autoplayPolicy,
expectedAutoplayPolicy,
`Autoplay policy is correct.`
);
}
add_task(async function testAutoplayPolicy() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: PAGE,
},
async browser => {
info(`- Allow all kinds of media to autoplay -`);
let isAllowedAutoplay = true;
let isAllowedMuted = true;
await setupTestPreferences(isAllowedAutoplay, isAllowedMuted);
await SpecialPowers.spawn(browser, ["allowed"], checkAutoplayPolicy);
info(
`- Allow all kinds of media to autoplay even if changing the pref for muted media -`
);
isAllowedAutoplay = true;
isAllowedMuted = false;
await setupTestPreferences(isAllowedAutoplay, isAllowedMuted);
await SpecialPowers.spawn(browser, ["allowed"], checkAutoplayPolicy);
info(`- Disable autoplay for audible media -`);
isAllowedAutoplay = false;
isAllowedMuted = true;
await setupTestPreferences(isAllowedAutoplay, isAllowedMuted);
await SpecialPowers.spawn(
browser,
["allowed-muted"],
checkAutoplayPolicy
);
info(`- Disable autoplay for all kinds of media -`);
isAllowedAutoplay = false;
isAllowedMuted = false;
await setupTestPreferences(isAllowedAutoplay, isAllowedMuted);
await SpecialPowers.spawn(browser, ["disallowed"], checkAutoplayPolicy);
info(
`- Simulate user gesture activation which would allow all kinds of media to autoplay -`
);
await SpecialPowers.spawn(browser, [], async () => {
content.document.notifyUserGestureActivation();
});
await SpecialPowers.spawn(browser, ["allowed"], checkAutoplayPolicy);
}
);
});

Просмотреть файл

@ -565,12 +565,6 @@ enum DocumentAutoplayPolicy {
"disallowed" // autoplay is not current allowed
};
// https://github.com/WICG/autoplay/issues/1
partial interface Document {
[Pref="dom.media.autoplay.autoplay-policy-api"]
readonly attribute DocumentAutoplayPolicy autoplayPolicy;
};
// Extension to give chrome JS the ability to determine whether
// the user has interacted with the document or not.
partial interface Document {

Просмотреть файл

@ -3062,14 +3062,6 @@
value: true
mirror: always
# This pref is used to enable/disable the `document.autoplayPolicy` API which
# returns a enum string which presents current autoplay policy and can change
# overtime based on user session activity.
- name: dom.media.autoplay.autoplay-policy-api
type: bool
value: false
mirror: always
# Autoplay Policy Detection https://w3c.github.io/autoplay/
- name: dom.media.autoplay-policy-detection.enabled
type: RelaxedAtomicBool