Bug 853356 - Test: Check mediastream track according to request type. r=jsmith
☠☠ backed out by 75c0c92d7fa4 ☠ ☠
authorAlfredo Yang <ayang@mozilla.com>
Mon, 09 Dec 2013 09:35:03 -0500
changeset 175568 144cec97320a6a543a89f3f48f3d72d3690c5015
parent 175567 b51aded2e62194d4d764ee91ca288db156cc6bc0
child 175569 2c25b5abfd17d152b29e04ae015a0000abd00175
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsmith
bugs853356
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 853356 - Test: Check mediastream track according to request type. r=jsmith
dom/media/tests/mochitest/Makefile.in
dom/media/tests/mochitest/test_getUserMedia_permission.html
--- a/dom/media/tests/mochitest/Makefile.in
+++ b/dom/media/tests/mochitest/Makefile.in
@@ -2,8 +2,14 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # The following tests are leaking and cannot be run by default yet
 ifdef MOZ_WEBRTC_LEAKING_TESTS
 MOCHITEST_FILES += \
   $(NULL)
 endif
+
+ifdef MOZ_B2G_CAMERA
+MOCHITEST_FILES += \
+  test_getUserMedia_permission.html \
+  $(NULL)
+endif
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_permission.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=853356
+-->
+<head>
+  <meta charset="utf-8">
+  <title>mozGetUserMedia Permission Test</title>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="head.js"></script>
+  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=853356">Display camera/microphone permission acquisition prompt</a>
+<script type="application/javascript">
+
+var gCount = 0;
+var gTests = [
+  {
+    constraints: {video: true, audio: false}
+  }
+  ,
+  {
+    constraints: {video: false, audio: true}
+  }
+  ,
+  {
+    constraints: {video: true, audio: true},
+  }
+  ];
+
+function gUM(data) {
+  var gum_success = function (stream) {
+    SimpleTest.info("TEST-INFO | Got succss callback for " + JSON.stringify(data.constraints));
+
+    var hasAudioTrack = stream.getAudioTracks().length > 0;
+    var hasVideoTrack = stream.getVideoTracks().length > 0;
+
+    is(data.constraints.audio, hasAudioTrack, "Request audio track:" +
+                  data.constraints.audio + " contain audio track:" + hasAudioTrack);
+    is(data.constraints.video, hasVideoTrack, "Request video track:" +
+                  data.constraints.video + " contain audio track:" + hasVideoTrack);
+    gCount++;
+    if (gCount < gTests.length) {
+      gUM(gTests[gCount]);
+    } else {
+      SimpleTest.finish();
+    }
+  }
+
+  var gum_fail = function () {
+    ok(false, "permission not granted for " + JSON.stringify(data.constraints));
+
+    SimpleTest.finish();
+  }
+
+  SimpleTest.info("TEST-INFO | Call getUserMedia for " + JSON.stringify(data.constraints));
+  navigator.mozGetUserMedia(data.constraints, gum_success, gum_fail);
+}
+
+SpecialPowers.pushPrefEnv({"set": [["media.navigator.permission.disabled", false]]},
+  function () {
+    SpecialPowers.addPermission('video-capture',
+                                Ci.nsIPermissionManager.ALLOW_ACTION, document);
+    SpecialPowers.addPermission('audio-capture',
+                                Ci.nsIPermissionManager.ALLOW_ACTION, document);
+
+    gUM(gTests[gCount]);
+  });
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>