tor-browser

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

test_hevc_playback.html (3498B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Test HEVC video playback</title>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <script type="text/javascript" src="manifest.js"></script>
      7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      8 <script type="application/javascript">
      9 
     10 /**
     11 * This test is used to check whether non-MSE HEVC video can be played on the
     12 * platform. HEVC can only be played if we have platform decoder supports
     13 * hardware decoding. Currently we can only do that on Windows.
     14 */
     15 add_task(async function testHEVCPlayback() {
     16  let video = document.createElement('video');
     17  info(`try to play HEVC video`);
     18  video.src = "hevc_white_frame.mp4";
     19  video.controls = true;
     20  document.body.appendChild(video);
     21  ok(await video.play().then(_=>true, _=>false), "video started playing");
     22  ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
     23     "video played to end");
     24  removeNodeAndSource(video);
     25 });
     26 
     27 
     28 // This test video contains an inband SPS that is different from the SPS in the
     29 // extradata, so we would recreate a new decoder.
     30 add_task(async function testHEVCInbandConfigChange() {
     31  let video = document.createElement('video');
     32  info(`try to play HEVC video`);
     33  video.src = "hevc_white_red_frames.mp4";
     34  video.playbackRate = 2.0; // speed up the test.
     35  video.controls = true;
     36  document.body.appendChild(video);
     37  ok(await video.play().then(_=>true, _=>false), "video started playing");
     38  // This video contains two resolutions, so we should expect to receive a
     39  // resize event during the playback.
     40  await Promise.all([
     41      new Promise(r => video.onended = r),
     42      new Promise(r => video.onresize = r)
     43  ]);
     44  ok(true, "video played to end and got a resize");
     45  removeNodeAndSource(video);
     46 });
     47 
     48 add_task(async function test8BitAnd10BitHEVC() {
     49  const files = ['gizmo_hevc_8bit_420.mp4', 'gizmo_hevc_10bit_420.mp4'];
     50  for (let file of files) {
     51    let video = document.createElement('video');
     52    info(`try to play ${file}`);
     53    video.src = file;
     54    video.controls = true;
     55    document.body.appendChild(video);
     56    ok(await video.play().then(_=>true, _=>false), "video started playing");
     57    ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
     58       "video played to end");
     59    removeNodeAndSource(video);
     60  }
     61 });
     62 
     63 add_task(async function testHEVCAspectRatio() {
     64  // The video resolution is 1440x1080, but its Display Aspect Ratio (DAR) is
     65  // influenced by different Sample Aspect Ratios (SARs), which adjust how the
     66  // image is stretched when displayed.
     67  const tests = [
     68    { file: 'aspect_ratio_4_3_hevc.mp4',
     69      expectedWidth: 1920,
     70      expectedHeight: 1080,
     71    }, {
     72      file: 'aspect_ratio_5_2_hevc.mp4',
     73      expectedWidth: 3600,
     74      expectedHeight: 1080,
     75    }];
     76  for (let test of tests) {
     77    let video = document.createElement('video');
     78    info(`try to play ${test.file}`);
     79    video.src = test.file;
     80    video.controls = true;
     81    document.body.appendChild(video);
     82    ok(await video.play().then(_=>true, _=>false), "video started playing");
     83    is(video.videoWidth, test.expectedWidth, `expect width ${test.expectedWidth}, actual width ${video.videoWidth}`);
     84    is(video.videoHeight, test.expectedHeight, `expect height ${test.expectedHeight}, actual height ${video.videoHeight}`);
     85    ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
     86       "video played to end");
     87    removeNodeAndSource(video);
     88  }
     89 });
     90 
     91 </script>
     92 </head>
     93 <body>
     94 </body>
     95 </html>