Bug 1718709 - part3 : add test. r=bryce

Differential Revision: https://phabricator.services.mozilla.com/D119698
This commit is contained in:
alwu 2021-07-14 00:28:29 +00:00
Родитель eb1dabe129
Коммит e685d89f2e
4 изменённых файлов: 52 добавлений и 0 удалений

Двоичные данные
dom/media/mediasource/test/bug1718709_high_res.mp4 Normal file

Двоичный файл не отображается.

Двоичные данные
dom/media/mediasource/test/bug1718709_low_res.mp4 Normal file

Двоичный файл не отображается.

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

@ -53,6 +53,8 @@ support-files =
init-trackid2.mp4^headers^ init-trackid3.mp4^headers^ segment-2.0001.m4s^headers^ segment-2.0002.m4s^headers^
segment-3.0001.m4s^headers^ segment-3.0002.m4s^headers^
wmf_mismatchedaudiotime.mp4
bug1718709_low_res.mp4
bug1718709_high_res.mp4
[test_AbortAfterPartialMediaSegment.html]
[test_AppendPartialInitSegment.html]
@ -100,6 +102,7 @@ skip-if = os == 'win' # bug 1487973,
[test_PlayEventsAutoPlaying.html]
[test_PlayEventsAutoPlaying2.html]
[test_RemoveSourceBuffer.html]
[test_Resolution_change_should_not_cause_video_freeze.html]
[test_ResumeAfterClearing_mp4.html]
[test_SeekableBeforeAndAfterEndOfStream.html]
[test_SeekableBeforeAndAfterEndOfStream_mp4.html]

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

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: video resolution changes during playback should not cause video freeze (Bug 1718709)</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, v) => {
await once(ms, "sourceopen");
const sb = ms.addSourceBuffer('video/mp4');
sb.appendBuffer(new Uint8Array(await fetchWithXHR("bug1718709_low_res.mp4")));
ok(true, "appended low resolution video");
sb.appendBuffer(new Uint8Array(await fetchWithXHR("bug1718709_high_res.mp4")));
ok(true, "appended high resolution video");
info(`start from the position which is near to the place where resolution changes`);
v.currentTime = 13;
ok(await v.play().then(_=>true,_=>false), "video started playing");
// When video resolution changes, it should not cause video freeze so we check
// its painted frame amount regularly to see if we stop updating video frames.
let lastPaintedFramesAmount = v.mozPaintedFrames;
const intervalHandle = setInterval(_=>{
ok(lastPaintedFramesAmount < v.mozPaintedFrames,
`painted frames keeps growing from ${lastPaintedFramesAmount} to ${v.mozPaintedFrames}`);
lastPaintedFramesAmount = v.mozPaintedFrames;
}, 1000);
// As we didn't append full video, so we will receive `waiting` event later
// which indicates that we can stop testing because we've finished playing
// the high resolution part.
await new Promise(r => {
v.onwaiting = _ => {
clearInterval(intervalHandle);
r();
}
});
SimpleTest.finish();
});
</script>
</body>
</html>