OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src=../../resources/testharness.js></script> |
| 3 <script src=../../resources/testharnessreport.js></script> |
| 4 <body> |
| 5 <canvas id='canvas' width=10 height=10/> |
| 6 </body> |
| 7 <script> |
| 8 |
| 9 const constraints = { whiteBalanceMode : "manual", |
| 10 exposureMode : "continuous", |
| 11 focusMode : "single-shot", |
| 12 |
| 13 exposureCompensation : 133.77, |
| 14 colorTemperature : 6000, |
| 15 iso : 120.0, |
| 16 |
| 17 brightness : 3, |
| 18 contrast : 4, |
| 19 saturation : 5, |
| 20 sharpness : 6, |
| 21 |
| 22 zoom : 3.141592 |
| 23 // TODO: torch https://crbug.com/700607. |
| 24 }; |
| 25 |
| 26 var canvas = document.getElementById('canvas'); |
| 27 var context = canvas.getContext("2d"); |
| 28 context.fillStyle = "red"; |
| 29 context.fillRect(0, 0, 10, 10); |
| 30 |
| 31 // These tests verify that MediaStreamTrack.getConstraints() exists and that, |
| 32 // returns the constraints passed beforehand with applyConstraints. |
| 33 var makeAsyncTest = function(c) { |
| 34 async_test(function(t) { |
| 35 var stream = canvas.captureStream(); |
| 36 var videoTrack = stream.getVideoTracks()[0]; |
| 37 |
| 38 const constraintsIn = { advanced : [ c ]}; |
| 39 |
| 40 // Method applyConstraints() will fail since there is no Image Capture |
| 41 // service in this Layout Test, but |constraintsIn| should be cached. |
| 42 videoTrack.applyConstraints(constraintsIn) |
| 43 .then(() => { /* ignore */ }) |
| 44 .catch((e) => { /* ignore */ }) |
| 45 .then(() => { |
| 46 const constraintsOut = videoTrack.getConstraints(); |
| 47 assert_object_equals(constraintsOut, constraintsIn, "constraints"); |
| 48 t.done(); |
| 49 }); |
| 50 |
| 51 }); |
| 52 }; |
| 53 |
| 54 // Send each line of |constraints| in turn and then the whole dictionary. |
| 55 for (key in constraints) { |
| 56 var one_constraint = {}; |
| 57 one_constraint[key] = constraints[key]; |
| 58 generate_tests( |
| 59 makeAsyncTest, |
| 60 [[ 'MediaStreamTrack.getConstraints(), key: ' + key, one_constraint ]]); |
| 61 } |
| 62 |
| 63 generate_tests(makeAsyncTest, [[ |
| 64 'MediaStreamTrack.getConstraints(), complete ', constraints |
| 65 ]]); |
| 66 |
| 67 </script> |
OLD | NEW |