content/media/test/test_VideoPlaybackQuality.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test basic functionality of VideoPlaybackQuality</title>
     5   <script type="text/javascript" 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">
    12 SimpleTest.waitForExplicitFinish();
    14 function test() {
    15   var video = document.createElement("video");
    16   ok(video.getVideoPlaybackQuality, "getVideoPlaybackQuality should be exposed with pref set");
    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   is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
    25   var vpq2 = video.getVideoPlaybackQuality();
    26   ok(vpq !== vpq2, "getVideoPlaybackQuality should return a new object");
    27   ok(vpq.creationTime <= vpq2.creationTime, "VideoPlaybackQuality objects should have increasing creationTime");
    29   var audio = document.createElement("audio");
    30   ok(!audio.getVideoPlaybackQuality, "getVideoPlaybackQuality should not be available on Audio elements");
    32   video.src = "seek.webm";
    33   video.play();
    34   video.addEventListener("ended", function () {
    35     vpq = video.getVideoPlaybackQuality();
    36     ok(vpq.creationTime <= performance.now(), "creationTime should be in the past");
    37     ok(vpq.totalVideoFrames > 0, "totalVideoFrames should be > 0");
    38     ok(vpq.droppedVideoFrames >= 0, "droppedVideoFrames should be >= 0");
    39     ok(vpq.corruptedVideoFrames >= 0, "corruptedVideoFrames should be >= 0");
    41     SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, function () {
    42       vpq = video.getVideoPlaybackQuality();
    43       is(vpq.creationTime, 0, "creationTime should be 0");
    44       is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0");
    45       is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0");
    46       is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0");
    48       SimpleTest.finish();
    49     });
    50   });
    51 }
    53 addLoadEvent(function() {
    54   SpecialPowers.pushPrefEnv({"set": [["media.mediasource.enabled", true]]}, test);
    55 });
    56 </script>
    57 </pre>
    58 </body>
    59 </html>

mercurial