content/media/test/test_VideoPlaybackQuality.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_VideoPlaybackQuality.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test basic functionality of VideoPlaybackQuality</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +</head>
    1.11 +<body>
    1.12 +<pre id="test">
    1.13 +<script class="testbody" type="text/javascript">
    1.14 +
    1.15 +SimpleTest.waitForExplicitFinish();
    1.16 +
    1.17 +function test() {
    1.18 +  var video = document.createElement("video");
    1.19 +  ok(video.getVideoPlaybackQuality, "getVideoPlaybackQuality should be exposed with pref set");
    1.20 +
    1.21 +  var vpq = video.getVideoPlaybackQuality();
    1.22 +  ok(vpq, "getVideoPlaybackQuality should return an object");
    1.23 +  ok(vpq.creationTime <= performance.now(), "creationTime should be in the past");
    1.24 +  is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0");
    1.25 +  is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0");
    1.26 +  is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
    1.27 +
    1.28 +  var vpq2 = video.getVideoPlaybackQuality();
    1.29 +  ok(vpq !== vpq2, "getVideoPlaybackQuality should return a new object");
    1.30 +  ok(vpq.creationTime <= vpq2.creationTime, "VideoPlaybackQuality objects should have increasing creationTime");
    1.31 +
    1.32 +  var audio = document.createElement("audio");
    1.33 +  ok(!audio.getVideoPlaybackQuality, "getVideoPlaybackQuality should not be available on Audio elements");
    1.34 +
    1.35 +  video.src = "seek.webm";
    1.36 +  video.play();
    1.37 +  video.addEventListener("ended", function () {
    1.38 +    vpq = video.getVideoPlaybackQuality();
    1.39 +    ok(vpq.creationTime <= performance.now(), "creationTime should be in the past");
    1.40 +    ok(vpq.totalVideoFrames > 0, "totalVideoFrames should be > 0");
    1.41 +    ok(vpq.droppedVideoFrames >= 0, "droppedVideoFrames should be >= 0");
    1.42 +    ok(vpq.corruptedVideoFrames >= 0, "corruptedVideoFrames should be >= 0");
    1.43 +
    1.44 +    SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, function () {
    1.45 +      vpq = video.getVideoPlaybackQuality();
    1.46 +      is(vpq.creationTime, 0, "creationTime should be 0");
    1.47 +      is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0");
    1.48 +      is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0");
    1.49 +      is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
    1.50 +
    1.51 +      SimpleTest.finish();
    1.52 +    });
    1.53 +  });
    1.54 +}
    1.55 +
    1.56 +addLoadEvent(function() {
    1.57 +  SpecialPowers.pushPrefEnv({"set": [["media.mediasource.enabled", true]]}, test);
    1.58 +});
    1.59 +</script>
    1.60 +</pre>
    1.61 +</body>
    1.62 +</html>

mercurial