tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mediasource-play.html (2575B)


      1 <!DOCTYPE html>
      2 <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
      3 <html>
      4    <head>
      5        <title>Simple MediaSource playback test case.</title>
      6        <meta name="timeout" content="long">
      7        <script src="/resources/testharness.js"></script>
      8        <script src="/resources/testharnessreport.js"></script>
      9        <script src="mediasource-util.js"></script>
     10    </head>
     11    <body>
     12        <div id="log"></div>
     13        <script>
     14          mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
     15          {
     16              mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
     17              mediaElement.addEventListener('ended', test.step_func_done());
     18 
     19              test.expectEvent(sourceBuffer, 'updatestart', 'sourceBuffer');
     20              test.expectEvent(sourceBuffer, 'update', 'sourceBuffer');
     21              test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
     22 
     23              assert_false(sourceBuffer.updating, "sourceBuffer.updating");
     24 
     25              sourceBuffer.appendBuffer(mediaData);
     26 
     27              assert_true(sourceBuffer.updating, "sourceBuffer.updating");
     28 
     29              test.waitForExpectedEvents(function()
     30              {
     31                  assert_false(sourceBuffer.updating, "sourceBuffer.updating");
     32 
     33                  // Truncate the buffered media to about 1 second duration.
     34                  sourceBuffer.remove(1, +Infinity);
     35 
     36                  assert_true(sourceBuffer.updating, "sourceBuffer.updating");
     37                  test.expectEvent(sourceBuffer, 'updatestart', 'sourceBuffer');
     38                  test.expectEvent(sourceBuffer, 'update', 'sourceBuffer');
     39                  test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
     40              });
     41 
     42              test.waitForExpectedEvents(function()
     43              {
     44                  assert_false(sourceBuffer.updating, "updating");
     45                  assert_greater_than(mediaSource.duration, 1, "duration");
     46 
     47                  // Complete truncation of duration to 1 second.
     48                  mediaSource.duration = 1;
     49 
     50                  test.expectEvent(mediaElement, "durationchange");
     51              });
     52 
     53              test.waitForExpectedEvents(function()
     54              {
     55                  mediaSource.endOfStream();
     56                  mediaElement.play();
     57              });
     58          }, "Test normal playback case with MediaSource API");
     59        </script>
     60    </body>
     61 </html>