author Timothy Guan-tin Chien <>
Wed, 21 Mar 2018 15:10:20 +0800
changeset 409397 e0c831e585307f722073cc4447092558dd0d1b51
parent 391685 87bd99540f77d1a2d8135f70f04bdea5ea660121
child 409403 99fc41ec7ce98a3617b8dc4e5198fff23565cf6a
permissions -rw-r--r--
Bug 1444489 - Part II, Replace touchControls with videoControls and remove touchControls r=Gijs Also migrates TouchUtils to videoControls in order to keep some interactions. Removed the casting button from TouchUtils (to be add back to Utils in the next commit; not removing the SVG images for hg annotation) MozReview-Commit-ID: DzhmjykCLzu

  <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" />
<p id="display"></p>

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

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

    // Wait for the fade out transition to complete in case the throbber
    // shows up on slower platforms.
    await SimpleTest.promiseWaitForCondition(() => 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 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}`);