test_VideoPlaybackQuality.html (2238B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test basic functionality of VideoPlaybackQuality</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <pre id="test"> 10 <script class="testbody" type="text/javascript"> 11 12 SimpleTest.waitForExplicitFinish(); 13 14 function test() { 15 var video = document.createElement("video"); 16 ok(video.getVideoPlaybackQuality, "getVideoPlaybackQuality should be exposed with pref set"); 17 18 var vpq = video.getVideoPlaybackQuality(); 19 ok(vpq, "getVideoPlaybackQuality should return an object"); 20 ok(vpq.creationTime <= performance.now(), "creationTime should be in the past"); 21 is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0"); 22 is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0"); 23 24 var vpq2 = video.getVideoPlaybackQuality(); 25 ok(vpq !== vpq2, "getVideoPlaybackQuality should return a new object"); 26 ok(vpq.creationTime <= vpq2.creationTime, "VideoPlaybackQuality objects should have increasing creationTime"); 27 28 var audio = document.createElement("audio"); 29 ok(!audio.getVideoPlaybackQuality, "getVideoPlaybackQuality should not be available on Audio elements"); 30 31 video.src = "seek.webm"; 32 video.play(); 33 video.addEventListener("ended", function () { 34 vpq = video.getVideoPlaybackQuality(); 35 ok(vpq.creationTime <= performance.now(), "creationTime should be in the past"); 36 ok(vpq.totalVideoFrames > 0, "totalVideoFrames should be > 0"); 37 ok(vpq.droppedVideoFrames >= 0, "droppedVideoFrames should be >= 0"); 38 ok(vpq.droppedVideoFrames <= vpq.totalVideoFrames, "droppedVideoFrames should be <= totalVideoFrames"); 39 40 SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, function () { 41 vpq = video.getVideoPlaybackQuality(); 42 is(vpq.creationTime, 0, "creationTime should be 0"); 43 is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0"); 44 is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0"); 45 46 SimpleTest.finish(); 47 }); 48 }); 49 } 50 51 addLoadEvent(function() { 52 SpecialPowers.pushPrefEnv({"set": 53 [ 54 ["media.mediasource.enabled", true], 55 ] 56 }, test); 57 }); 58 </script> 59 </pre> 60 </body> 61 </html>