зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435133 - Test that we delay media play start until we know whether a media has audio or not. r=bryce
Test that play() on a media without audio called before readyState >= HAVE_METADATA will still play. MozReview-Commit-ID: 1FeDrEfCEum --HG-- extra : rebase_source : be6d07905aad853ad028eac372e4e380bdeb1a49 extra : source : e98b4a7aaf020fa3d6d59cb0f53680ef6466d154
This commit is contained in:
Родитель
04c2da8b9e
Коммит
79ee61bdff
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Autoplay policy window</title>
|
||||
<style>
|
||||
video {
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="AutoplayTestUtils.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
|
||||
window.is = window.opener.is;
|
||||
window.info = window.opener.info;
|
||||
|
||||
async function testPlayBeforeLoadedMetata(testCase, parent_window) {
|
||||
info("testPlayBeforeLoadedMetata: " + testCase.resource);
|
||||
|
||||
let element = document.createElement("video");
|
||||
element.preload = "auto";
|
||||
element.src = testCase.resource;
|
||||
document.body.appendChild(element);
|
||||
|
||||
let played = await element.play().then(() => true, () => false);
|
||||
let msg = testCase.resource + " should " + (!testCase.shouldPlay ? "not " : "") + "play";
|
||||
is(played, testCase.shouldPlay, msg);
|
||||
|
||||
removeNodeAndSource(element);
|
||||
}
|
||||
|
||||
nextWindowMessage().then(
|
||||
async (event) => {
|
||||
await testPlayBeforeLoadedMetata(event.data, event.source);
|
||||
event.source.postMessage("done", "*");
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -440,6 +440,7 @@ support-files =
|
|||
file_autoplay_policy_unmute_pauses.html
|
||||
file_autoplay_policy_activation_window.html
|
||||
file_autoplay_policy_activation_frame.html
|
||||
file_autoplay_policy_play_before_loadedmetadata.html
|
||||
flac-s24.flac
|
||||
flac-s24.flac^headers^
|
||||
flac-noheader-s16.flac
|
||||
|
@ -695,6 +696,8 @@ skip-if = android_version == '23' # bug 1424903
|
|||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_autoplay_policy_unmute_pauses.html]
|
||||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_autoplay_policy_play_before_loadedmetadata.html]
|
||||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_buffered.html]
|
||||
skip-if = android_version == '15' || android_version == '22' # bug 1308388, android(bug 1232305)
|
||||
[test_bug448534.html]
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Autoplay policy test</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="AutoplayTestUtils.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
|
||||
window.is = SimpleTest.is;
|
||||
window.info = SimpleTest.info;
|
||||
|
||||
// Tests that videos which have no audio track will play if play()
|
||||
// is called before the video has reached readyState >= HAVE_METADATA.
|
||||
|
||||
gTestPrefs.push(["media.autoplay.enabled", false],
|
||||
["media.autoplay.enabled.user-gestures-needed", true]);
|
||||
|
||||
SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => {
|
||||
runTest();
|
||||
});
|
||||
|
||||
let testCases = [
|
||||
{
|
||||
resource: "320x240.ogv", // Only video track.
|
||||
shouldPlay: true,
|
||||
},
|
||||
{
|
||||
resource: "short.mp4", // Audio and video track.
|
||||
shouldPlay: false,
|
||||
},
|
||||
];
|
||||
|
||||
let child_url = "file_autoplay_policy_play_before_loadedmetadata.html";
|
||||
|
||||
async function runTest() {
|
||||
for (testCase of testCases) {
|
||||
// Run each test in a new window, to ensure its user gesture
|
||||
// activation state isn't tainted by preceeding tests.
|
||||
let child = window.open(child_url, "", "width=500,height=500");
|
||||
await once(child, "load");
|
||||
child.postMessage(testCase, window.origin);
|
||||
let result = await nextWindowMessage();
|
||||
child.close();
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче