content/media/test/test_chaining.html

Thu, 15 Jan 2015 21:13:52 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:13:52 +0100
branch
TOR_BUG_9701
changeset 12
7540298fafa1
permissions
-rw-r--r--

Remove forgotten relic of ABI crash risk averse overloaded method change.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Media test: chained ogg files.</title>
     5   <meta charset='utf-8'>
     6   <script type="text/javascript" src="/MochiKit/Base.js"></script>
     7   <script type="text/javascript" src="/MochiKit/DOM.js"></script>
     8   <script type="text/javascript" src="/MochiKit/Style.js"></script>
     9   <script type="text/javascript" src="/MochiKit/Signal.js"></script>
    10   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    11   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    12   <script type="text/javascript" src="manifest.js"></script>
    13 </head>
    14 <body>
    15 <pre id="test">
    16 <script class="testbody" type="text/javascript">
    17 var manager = new MediaTestManager;
    19 function finish_test(element) {
    20   if (element.parentNode)
    21     element.parentNode.removeChild(element);
    22   manager.finished(element.token);
    23 }
    25 function onended(e) {
    26   var t = e.target;
    27   is(t._metadataCount, t._links, "We should have received "+ t._links +
    28      " metadataloaded event. " + t.src);
    30   // If we encounter a file that has links with a different numbers of channel,
    31   // we stop the decoding at the end of the first link. Hence, we report normal
    32   // |seekable| and |buffered| values.
    33   if (t._links != 1) {
    34     is(t.seekable.length, 0, "No seekable ranges should be reported." + t.src);
    35     is(t.buffered.length, 0, "No buffered region should be reported." + t.src);
    36   }
    38   is(t.played.length, 1, "The played region should be continuous." + t.src);
    40   if (t._links != 1) {
    41     var oldCurrentTime = t.currentTime;
    42     t.currentTime = 0.0;
    43     is(t.currentTime, oldCurrentTime,
    44         "Seeking should be disabled when playing chained media." + t.src);
    45   }
    47   finish_test(t);
    48 }
    50 function onmetadataloaded(e) {
    51   var t = e.target;
    52   if (! t._metadataCount) {
    53     t._metadataCount = 0;
    54   }
    56   if (t._metadataCount > 1 && t._links === 1) {
    57     ok(false, "We should receive only one \"loadedmetadata\" event for a chained file we don't support.")
    58   }
    60   // We should be able to assert equality here, but somehow it fails (rarely but
    61   // still) on try. Instead, we give it a little slack and assert that the index
    62   // increases monotonically.
    63   ok(t.mozGetMetadata().index >= t._metadataCount || t._links === 1,
    64      "The metadata index value should increase." + t.src);
    66   // The files have all a user comment name 'index' that increments at each link
    67   // in the chained media.
    68   t._metadataCount++;
    69   if (!t.playing && !t.ended) {
    70     t.play();
    71   }
    72 }
    74 function startTest(test, token) {
    75   var elemType = /^audio/.test(test.type) ? "audio" : "video";
    76   var element = document.createElement(elemType);
    77   document.body.appendChild(element);
    78   manager.started(token);
    79   element._links= test.links;
    80   element.src = test.name;
    81   element.token = token;
    82   element.controls = true;
    83   element.addEventListener("loadedmetadata", onmetadataloaded);
    84   element.addEventListener("ended", onended);
    85 }
    87 manager.runTests(gChainingTests, startTest);
    88 </script>
    89 </pre>
    90 </body>
    91 </html>

mercurial