toolkit/content/tests/widgets/test_videocontrols_error.html
author Timothy Guan-tin Chien <timdream@gmail.com>
Fri, 16 Mar 2018 06:55:58 +0800
changeset 409403 99fc41ec7ce98a3617b8dc4e5198fff23565cf6a
parent 409397 e0c831e585307f722073cc4447092558dd0d1b51
child 411594 c6e628dc585f3d7f91016f7b3f87e790c0a7a8a6
permissions -rw-r--r--
Bug 1444489 - Part VIII, Transition the visibility property instead of using transitionend event r=Gijs Fades out all the UIs by applying CSS transition on opacity and visibility. Stop relying on transitionend event to set the hidden state. This removes a source of intermittent failure and while making sure UIs are hidden. MozReview-Commit-ID: FR7JQn4eO3X

<!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));
    });

    await SimpleTest.promiseWaitForCondition(() => statusOverlay.hasAttribute("fadeout") || statusOverlay.hidden,
      "statusOverlay should 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.hasAttribute("fadeout"), `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>