Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/imagecapture/setOptions-reject.html |
| diff --git a/third_party/WebKit/LayoutTests/imagecapture/setOptions-reject.html b/third_party/WebKit/LayoutTests/imagecapture/setOptions-reject.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d17e52bc504171d85a03cf20e51a41c9e80259fc |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/imagecapture/setOptions-reject.html |
| @@ -0,0 +1,61 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/mock-imagecapture.js"></script> |
| +<body> |
| +<canvas id='canvas' width=10 height=10/> |
| +</body> |
| +<script> |
| + |
| +var canvas = document.getElementById('canvas'); |
| +var context = canvas.getContext("2d"); |
| +context.fillStyle = "red"; |
| +context.fillRect(0, 0, 10, 10); |
| + |
| +// This test verifies that ImageCapture.setOptions() rejects if any passed |
| +// option is unsupported or outside its allowed range. |
| +var makePromiseTest = function(getOption) { |
| + promise_test(function(t) { |
| + var theMock = null; |
| + var theCapturer = null; |
| + return mockImageCaptureReady |
| + .then(mock => { |
| + theMock = mock; |
| + theMock.capabilities().red_eye_reduction = 0; |
| + |
| + var stream = canvas.captureStream(); |
| + return new ImageCapture(stream.getVideoTracks()[0]); |
| + }, |
| + error => { |
| + assert_unreached("Error creating MockImageCapture: " + error); |
| + }) |
| + .then(capturer => { |
| + theCapturer = capturer; |
| + return capturer.getPhotoCapabilities(); |
| + }) |
| + .then(c => { |
| + const options = getOption(theMock.capabilities()); |
| + return promise_rejects(t, "NotSupportedError", |
| + theCapturer.setOptions(options)); |
| + }); |
| + }); |
| +}; |
| + |
| +const optionsGenerators = [ |
| + (capabilities) => { return { redEyeReduction : true }; }, |
|
Reilly Grant (use Gerrit)
2017/05/15 16:50:48
Does the following not work?
capabilities => { re
mcasas
2017/05/15 18:18:49
The latter works.
|
| + (capabilities) => { return { imageHeight : capabilities.height.max + 1 }; }, |
| + (capabilities) => { return { imageHeight : capabilities.height.min - 1 }; }, |
| + (capabilities) => { return { imageWidth : capabilities.width.max + 1 }; }, |
| + (capabilities) => { return { imageWidth : capabilities.width.min - 1 }; }, |
| + (capabilities) => { return { fillLightMode : "off" }; }, |
| +]; |
| + |
| +for (key in optionsGenerators) { |
| + generate_tests( |
| + makePromiseTest, |
| + [[ 'ImageCapture.setOptions(options) rejects with bad options, #' + key, |
| + optionsGenerators[key] ]]); |
| +} |
| + |
| +</script> |