dom/media/test/test_playback_rate_playpause.html
author Dorel Luca <dluca@mozilla.com>
Sat, 12 Jan 2019 01:28:30 +0200
changeset 453595 c45da646fc6140bd59a36bda18f6cecde6163feb
parent 344958 a072d7934ff7c6fd2ad974d7abc0b08d11041aca
child 469641 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Backed out changeset 24243f13c895 (bug 1519308) for build bustage in mozbuild/mozbuild/test/configure/test_checks_configure.py. CLOSED TREE

<!DOCTYPE HTML>
<html>
<head>
  <title>Test that the playbackRate property is not reset when resuming the playback</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type='application/javascript'>

let manager = new MediaTestManager;

function ontimeupdate(e) {
  var t = e.target;
  if (t.currentTime != 0.0) {
    dump(t.token + " t.currentTime != 0.0.\n");
    t.removeEventListener("timeupdate", ontimeupdate);
    t.pause();
    is(t.playbackRate, 0.5, "PlaybackRate should not have changed after pause.");
  } else {
    dump(t.token + " t.currentTime == 0.0.\n");
  }
}

function onpaused(e) {
  var t = e.target;
  dump(t.token + " onpaused.\n");
  t.play();
  is(t.playbackRate, 0.5, "PlaybackRate should not have changed after resuming playback.");
  finish_test(t);
}

function finish_test(element) {
  dump(element.token + " finish_test.\n");
  removeNodeAndSource(element);
  manager.finished(element.token);
}

function startTest(test, token) {
  let elemType = /^audio/.test(test.type) ? "audio" : "video";
  let element = document.createElement(elemType);
  element.src = test.name;
  element.token = token;
  element.controls = true;
  element.playbackRate = 0.5;
  element.preload = "metadata";
  element.addEventListener("timeupdate", ontimeupdate);
  element.addEventListener("pause", onpaused);
  element.addEventListener("loadedmetadata", function() {
    dump(element.token + " loadedmetadata\n");
    element.play();
  });
  document.body.appendChild(element);
  manager.started(token);
}

manager.runTests(gPlayedTests, startTest);

</script>
</pre>
<div id="elements">
</div>
</body>
</html>