toolkit/content/tests/widgets/test_videocontrols_error.html
author Ray Lin <ralin@mozilla.com>
Sun, 12 Nov 2017 23:18:03 +0800
changeset 391685 87bd99540f77d1a2d8135f70f04bdea5ea660121
parent 391079 ead14db678204b84c56e6238f5069a93dfb0dadc
child 409397 e0c831e585307f722073cc4447092558dd0d1b51
permissions -rw-r--r--
Bug 1415596 - Make click to play button transparent when status overlay is present on video controls. r=jaws MozReview-Commit-ID: 6xweGJQoR6R

<!DOCTYPE HTML>
<html>
<head>
  <title>Video controls test - Error</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
  <script type="text/javascript" src="head.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>

<div id="content">
  <video id="video" controls preload="auto"></video>
</div>

<pre id="test">
<script clas="testbody" type="application/javascript">
  const video = document.getElementById("video");
  const statusOverlay = getAnonElementWithinVideoByAttribute(video, "anonid", "statusOverlay");
  const statusIcon = getAnonElementWithinVideoByAttribute(video, "anonid", "statusIcon");

  add_task(async function setup() {
    await new Promise(resolve => window.addEventListener("load", resolve, {once: true}));
    await SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]});
  });

  add_task(async function check_normal_status() {
    await new Promise(resolve => {
      video.src = "seek_with_sound.ogg";
      video.addEventListener("loadedmetadata", () => SimpleTest.executeSoon(resolve));
    });

    ok(statusOverlay.hidden, "statusOverlay shoud not present without error");
    ok(!statusOverlay.hasAttribute("error"), "statusOverlay should not in error state");
    isnot(statusIcon.getAttribute("type"), "error", "should not show error icon");
  });

  add_task(async function invalid_source() {
    const errorType = "errorNoSource";

    await new Promise(resolve => {
      video.src = "invalid_source.ogg";
      video.addEventListener("error", () => SimpleTest.executeSoon(resolve));
    });

    ok(!statusOverlay.hidden, `statusOverlay should show when ${errorType}`);
    is(statusOverlay.getAttribute("error"), errorType, `statusOverlay should have correct error state: ${errorType}`);
    is(statusIcon.getAttribute("type"), "error", `should show error icon when ${errorType}`);
  });
</script>
</pre>
</body>
</html>