DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (27a812186ff4)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=882145
-->
<head>
  <meta charset="utf-8">
  <title>Test mozGetUserMedia Constraints</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>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=882145">Test mozGetUserMedia Constraints</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script type="application/javascript">
/**
  Tests covering gUM constraints API for audio, video and fake video. Exercise
  successful parsing code and ensure that unknown mandatory constraints and
  overconstraining cases produce appropriate errors.
*/
var tests = [
  // Each test here tests a different constraint or codepath.
  { message: "video overconstrained by facingMode fails",
    constraints: { video: { mandatory: { facingMode:'left' } } },
    error: "NO_DEVICES_FOUND",
    pass: false },
  { message: "Success-path: optional video facingMode + audio ignoring facingMode",
    constraints: { fake: true,
                   audio: { mandatory: { facingMode:'left' } },
                   video: { mandatory: { somethingUnknown:0 },
                            optional: [{ facingMode:'left' },
                                       { facingMode:'right' },
                                       { facingMode:'environment' },
                                       { facingMode:'user' },
                                       { foo:0 }] } },
    error: null,
    pass: false },
  { message: null },
];

/**
 * Starts the test run by running through each constraint
 * test by verifying that the right callback and error message is fired.
 */

runTest(function () {
  var i = 0;
  next();

  function Success() {
    info("successcallback");
    tests[i].pass = !tests[i].error;
    i++;
    next();
  }
  function Failure(err) {
    info("errcallback: " + err);
    tests[i].pass = tests[i].error? (err === tests[i].error) : false;
    i++;
    next();
  }
  function next() {
    if (tests[i].message) {
      navigator.mozGetUserMedia(tests[i].constraints, Success, Failure);
    } else {
      finish();
    }
  }
  function finish() {
    tests.forEach(function (test) {
      if (test.message) {
        ok(test.pass, test.message);
      } else {
        SimpleTest.finish();
      }
    });
  }
});


</script>
</pre>
</body>
</html>