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