Bug 1302320 - add noaudio icon test for video control. r=jaws
authorRay Lin <ralin@mozilla.com>
Thu, 22 Sep 2016 15:30:48 +0800
changeset 323995 4e27de747d61e73f4f162012265f1e15c3f074af
parent 323994 7838378b57e73777ca80b2319b8124c8d8bf615f
child 323996 4d45db027c096f1038f47c748fdbd21e7effa7a4
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjaws
bugs1302320
milestone53.0a1
Bug 1302320 - add noaudio icon test for video control. r=jaws MozReview-Commit-ID: KfrsEJ3mgB6
toolkit/content/tests/widgets/mochitest.ini
toolkit/content/tests/widgets/test_videocontrols_video_noaudio.html
--- a/toolkit/content/tests/widgets/mochitest.ini
+++ b/toolkit/content/tests/widgets/mochitest.ini
@@ -1,13 +1,14 @@
 [DEFAULT]
 support-files =
   audio.wav
   audio.ogg
   seek_with_sound.ogg
+  video.ogg
   head.js
   tree_shared.js
   videocontrols_direction-1-ref.html
   videocontrols_direction-1a.html
   videocontrols_direction-1b.html
   videocontrols_direction-1c.html
   videocontrols_direction-1d.html
   videocontrols_direction-1e.html
@@ -32,10 +33,12 @@ skip-if = toolkit == 'android'
 [test_videocontrols_audio.html]
 [test_videocontrols_audio_direction.html]
 [test_videocontrols_jsdisabled.html]
 skip-if = toolkit == 'android' # bug 1272646
 [test_videocontrols_standalone.html]
 skip-if = toolkit == 'android' # bug 1075573
 [test_videocontrols_video_direction.html]
 skip-if = os == 'win'
+[test_videocontrols_video_noaudio.html]
+skip-if = toolkit == 'android'
 [test_bug898940.html]
 [test_videocontrols_error.html]
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/widgets/test_videocontrols_video_noaudio.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Video controls test</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.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">
+  SimpleTest.waitForExplicitFinish();
+
+  const domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
+    getService(SpecialPowers.Ci.inIDOMUtils);
+  const video = document.getElementById("video");
+  const muteButton = getElementByAttribute("class", "muteButton");
+  const volumeStack = getElementByAttribute("class", "volumeStack");
+  const testCases = [];
+
+  testCases.push(() => new Promise(resolve => {
+    is(muteButton.getAttribute("noAudio"), "true");
+    is(muteButton.getAttribute("disabled"), "true");
+
+    if (volumeStack) {
+      ok(volumeStack.hidden);
+    }
+
+    resolve();
+  }));
+
+  function executeTestCases(tasks) {
+    return tasks.reduce((promise, task) => promise.then(task), Promise.resolve());
+  }
+
+  function getElementByAttribute(aName, aValue) {
+    const videoControl = domUtils.getChildrenForNode(video, true)[1];
+
+    return SpecialPowers.wrap(document)
+      .getAnonymousElementByAttribute(videoControl, aName, aValue);
+  }
+
+  function loadedmetadata() {
+    executeTestCases(testCases).then(SimpleTest.finish);
+  }
+
+  function startMediaLoad() {
+    video.src = "video.ogg";
+    video.addEventListener("loadedmetadata", loadedmetadata, false);
+  }
+
+  function loadevent() {
+    SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startMediaLoad);
+  }
+
+  window.addEventListener("load", loadevent, false);
+</script>
+</pre>
+</body>
+</html>