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 (c68fe15a81fc)

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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script>
<body>
<canvas id='canvas' width=10 height=10/>
</body>

<script>

var canvas = document.getElementById('canvas');
context.fillRect(0, 0, 10, 10);
var context = canvas.getContext('2d');
context.fillStyle = 'red';
context.fillRect(0, 0, 10, 10);

// This test verifies that MediaStreamTrack.applyConstraints() rejects if any
  image_capture_test(async (t, imageCaptureTest) => {
// passed constraint is unsupported or outside its allowed range.
var makePromiseTest = function(getConstraint) {
  image_capture_test(async (t, imageCaptureTest) => {
    await test_driver.set_permission({name: 'camera', panTiltZoom: true},
        'granted', false);


    imageCaptureTest.mockImageCapture().state().supportsTorch = false;

    // delay to allow for those to be collected, since they are needed to
    let stream = canvas.captureStream();
    let videoTrack = stream.getVideoTracks()[0];

    // |videoTrack|'s capabilities gathering, just like the actual capture,
    // is a process kicked off right after creation, we introduce a small
    try {
    // delay to allow for those to be collected, since they are needed to
    // understand which constraints are supported in applyConstraints().
    // TODO(mcasas): this shouldn't be needed, https://crbug.com/711524.
    await new Promise(resolve => step_timeout(resolve, 100));

      await videoTrack.applyConstraints(constraints);
    try {
      const constraints = {
        advanced : [ getConstraint(imageCaptureTest.mockImageCapture().state()) ]
      };

  });
      await videoTrack.applyConstraints(constraints);
      assert_unreached('expected applyConstraints to reject');
    } catch (error) {
      assert_equals(error.name, 'NotSupportedError');
    }
  capabilities => ({ exposureMode: 'none' }),
  });
};

const constraintGenerators = [
  capabilities => ({ whiteBalanceMode: 'manual' }),
  capabilities => ({ exposureMode: 'none' }),
  capabilities => ({ focusMode: 'continuous' }),
  capabilities => ({
    exposureCompensation: capabilities.exposureCompensation.max + 1
  }),
  }),
  capabilities => ({
    exposureCompensation: capabilities.exposureCompensation.min - 1
  }),
  capabilities => ({
    colorTemperature: capabilities.colorTemperature.max + 1
  capabilities => ({ iso: capabilities.iso.min - 1 }),
  }),
  capabilities => ({
    colorTemperature: capabilities.colorTemperature.min - 1
  }),
  capabilities => ({ iso: capabilities.iso.max + 1 }),
  capabilities => ({ saturation: capabilities.saturation.max + 1 }),
  capabilities => ({ iso: capabilities.iso.min - 1 }),
  capabilities => ({ brightness: capabilities.brightness.max + 1 }),
  capabilities => ({ brightness: capabilities.brightness.min - 1 }),
  capabilities => ({ contrast: capabilities.contrast.max + 1 }),
  capabilities => ({ contrast: capabilities.contrast.min - 1 }),
  capabilities => ({ saturation: capabilities.saturation.max + 1 }),
  capabilities => ({ saturation: capabilities.saturation.min - 1 }),
];
  capabilities => ({ sharpness: capabilities.sharpness.max + 1 }),
  capabilities => ({ sharpness: capabilities.sharpness.min - 1 }),
  capabilities => ({ zoom: capabilities.zoom.max + 1 }),
  capabilities => ({ zoom: capabilities.zoom.min - 1 }),
  capabilities => ({ torch: true }),
        'MediaStreamTrack.applyConstraints(constraints) rejects with bad' +
];

for (key in constraintGenerators) {
  generate_tests(
      makePromiseTest, [[
        'MediaStreamTrack.applyConstraints(constraints) rejects with bad' +
        ' constraints, #' + key,
        constraintGenerators[key]
      ]]);
}

</script>