simple test for optional constraint
authorDominique Hazael-Massieux <dom@w3.org>
Mon, 03 Jun 2013 18:37:32 +0200
changeset 62 801d1521d150
parent 61 b3dfdf7687e6
child 63 a0bfdc3169c1
simple test for optional constraint
submitted/W3C/getusermedia-optional-constraint.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/getusermedia-optional-constraint.html	Mon Jun 03 18:37:32 2013 +0200
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+<head>
+<title>Optional constraint recognized as optional in getUserMedia</title>
+<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
+<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia">
+<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
+</head>
+<body>
+<p>When prompted, accept to share your video stream.</p>
+<h1>Description</h1>
+<p>This test checks that setting an optional constraint in getUserMedia is handled as optional</p>
+
+<div id='log'></div>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=featuredetection.js></script>
+<script src=prefix.js></script>
+<script>
+var t = async_test("Tests that setting an optional constraint in getUserMedia is handled as optional", {timeout:10000});
+t.step(function() {
+  navigator.getUserMedia({video: {optional: [{width: {min:1024}}, {width: {max: 800}}]}}, t.step_func(function (stream) {
+    assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track");
+    t.done();
+  }), t.step_func(function(error) {
+    assert_unreached("an optional constraint can't prevent the obtention of a video stream");
+    t.done();
+  }));
+});
+</script>
+</body>
+</html>