tor-browser

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

test_preserve_playbackrate_after_ui_play.html (1812B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title> Bug 1013933 - preserve playbackRate after clicking play button </title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script src="/tests/SimpleTest/EventUtils.js"></script>
      7  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      9 </head>
     10 <body>
     11 
     12 <div id="content">
     13  <video width="320" height="240" id="video" controls mozNoDynamicControls preload="auto"></video>
     14 </div>
     15 
     16 <script type="text/javascript">
     17 /*
     18 * Positions of the UI elements, relative to the upper-left corner of the
     19 * <video> box.
     20 */
     21 const videoHeight = 240;
     22 const playButtonWidth = 28;
     23 const playButtonHeight = 28;
     24 const playButtonCenterX = 0 + Math.round(playButtonWidth / 2);
     25 const playButtonCenterY = videoHeight - Math.round(playButtonHeight / 2);
     26 
     27 var expectedPlaybackRate = 0.5
     28 
     29 function runTest() {
     30  var video = document.getElementById("video");
     31  video.src = "audio.wav";
     32  video.loop = true;
     33  video.playbackRate = expectedPlaybackRate;
     34 
     35  video.oncanplaythrough = function() {
     36    video.oncanplaythrough = null;
     37    is(video.paused, true, "video is not playing yet.");
     38    is(video.playbackRate, expectedPlaybackRate,
     39       "playbackRate is correct before clicking play button.");
     40 
     41    // Click the play button
     42    synthesizeMouse(video, playButtonCenterX, playButtonCenterY, { });
     43  };
     44 
     45  video.onplay = function() {
     46    video.onplay = null;
     47    is(video.paused, false, "video starts playing.");
     48    is(video.playbackRate, expectedPlaybackRate,
     49       "playbackRate is correct after clicking play button.");
     50    video.pause();
     51    SimpleTest.finish();
     52  };
     53 }
     54 
     55 window.addEventListener("load", runTest);
     56 SimpleTest.waitForExplicitFinish();
     57 </script>
     58 </pre>
     59 </body>
     60 </html>