mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 889201 - Add tests for VideoPlaybackQuality. r=roc
This commit is contained in:
parent
b61fe1fbac
commit
dbcfe9d22f
@ -262,6 +262,12 @@ already_AddRefed<VideoPlaybackQuality>
|
||||
HTMLVideoElement::GetVideoPlaybackQuality()
|
||||
{
|
||||
DOMHighResTimeStamp creationTime = 0;
|
||||
uint64_t totalFrames = 0;
|
||||
uint64_t droppedFrames = 0;
|
||||
uint64_t corruptedFrames = 0;
|
||||
double playbackJitter = 0.0;
|
||||
|
||||
if (sVideoStatsEnabled) {
|
||||
nsPIDOMWindow* window = OwnerDoc()->GetInnerWindow();
|
||||
if (window) {
|
||||
nsPerformance* perf = window->GetPerformance();
|
||||
@ -270,17 +276,14 @@ HTMLVideoElement::GetVideoPlaybackQuality()
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t totalFrames = 0;
|
||||
uint64_t droppedFrames = 0;
|
||||
uint64_t corruptedFrames = 0;
|
||||
double playbackJitter = 0.0;
|
||||
if (mDecoder && sVideoStatsEnabled) {
|
||||
if (mDecoder) {
|
||||
MediaDecoder::FrameStatistics& stats = mDecoder->GetFrameStatistics();
|
||||
totalFrames = stats.GetParsedFrames();
|
||||
droppedFrames = totalFrames - stats.GetPresentedFrames();
|
||||
corruptedFrames = totalFrames - stats.GetDecodedFrames();
|
||||
playbackJitter = stats.GetPlaybackJitter();
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<VideoPlaybackQuality> playbackQuality =
|
||||
new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames,
|
||||
|
@ -141,6 +141,8 @@ MOCHITEST_FILES = \
|
||||
test_texttrackcue.html \
|
||||
test_timeupdate_small_files.html \
|
||||
test_unseekable.html \
|
||||
test_VideoPlaybackQuality.html \
|
||||
test_VideoPlaybackQuality_disabled.html \
|
||||
test_webvtt_disabled.html \
|
||||
$(NULL)
|
||||
|
||||
|
62
content/media/test/test_VideoPlaybackQuality.html
Normal file
62
content/media/test/test_VideoPlaybackQuality.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test basic functionality of VideoPlaybackQuality</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test() {
|
||||
var video = document.createElement("video");
|
||||
ok(video.getVideoPlaybackQuality, "getVideoPlaybackQuality should be exposed with pref set");
|
||||
|
||||
var vpq = video.getVideoPlaybackQuality();
|
||||
ok(vpq, "getVideoPlaybackQuality should return an object");
|
||||
ok(vpq.creationTime <= performance.now(), "creationTime should be in the past");
|
||||
is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0");
|
||||
is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0");
|
||||
is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
|
||||
is(vpq.playbackJitter, 0, "playbackJitter should be 0");
|
||||
|
||||
var vpq2 = video.getVideoPlaybackQuality();
|
||||
ok(vpq !== vpq2, "getVideoPlaybackQuality should return a new object");
|
||||
ok(vpq.creationTime <= vpq2.creationTime, "VideoPlaybackQuality objects should have increasing creationTime");
|
||||
|
||||
var audio = document.createElement("audio");
|
||||
ok(!audio.getVideoPlaybackQuality, "getVideoPlaybackQuality should not be available on Audio elements");
|
||||
|
||||
video.src = "seek.webm";
|
||||
video.play();
|
||||
video.addEventListener("ended", function () {
|
||||
vpq = video.getVideoPlaybackQuality();
|
||||
ok(vpq.creationTime <= performance.now(), "creationTime should be in the past");
|
||||
ok(vpq.totalVideoFrames > 0, "totalVideoFrames should be > 0");
|
||||
ok(vpq.droppedVideoFrames >= 0, "droppedVideoFrames should be >= 0");
|
||||
ok(vpq.corruptedVideoFrames >= 0, "corruptedVideoFrames should be >= 0");
|
||||
ok(vpq.playbackJitter >= 0, "playbackJitter should be >= 0");
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, function () {
|
||||
vpq = video.getVideoPlaybackQuality();
|
||||
is(vpq.creationTime, 0, "creationTime should be 0");
|
||||
is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0");
|
||||
is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0");
|
||||
is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
|
||||
is(vpq.playbackJitter, 0, "playbackJitter should be 0");
|
||||
});
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.mediasource.enabled", true]]}, test);
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
33
content/media/test/test_VideoPlaybackQuality_disabled.html
Normal file
33
content/media/test/test_VideoPlaybackQuality_disabled.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test basic functionality of VideoPlaybackQuality</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test() {
|
||||
var video = document.createElement("video");
|
||||
ok(!video.getVideoPlaybackQuality, "getVideoPlaybackQuality should be hidden behind a pref");
|
||||
var accessThrows = false;
|
||||
try {
|
||||
video.getVideoPlaybackQuality();
|
||||
} catch (e) {
|
||||
accessThrows = true;
|
||||
}
|
||||
ok(accessThrows, "getVideoPlaybackQuality should be hidden behind a pref");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.mediasource.enabled", false]]}, test);
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -12,6 +12,7 @@
|
||||
|
||||
[Pref="media.mediasource.enabled"]
|
||||
interface VideoPlaybackQuality {
|
||||
readonly attribute DOMHighResTimeStamp creationTime;
|
||||
readonly attribute unsigned long totalVideoFrames;
|
||||
readonly attribute unsigned long droppedVideoFrames;
|
||||
readonly attribute unsigned long corruptedVideoFrames;
|
||||
|
Loading…
Reference in New Issue
Block a user