Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: third_party/WebKit/LayoutTests/imagecapture/setOptions-reject.html

Issue 2877273002: Image Capture: reject setOptions()/applyConstraints() if any argument is unsupported (Closed)
Patch Set: reillyg@ comments and rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-imagecapture.js"></script>
6 <body>
7 <canvas id='canvas' width=10 height=10/>
8 </body>
9 <script>
10
11 var canvas = document.getElementById('canvas');
12 var context = canvas.getContext("2d");
13 context.fillStyle = "red";
14 context.fillRect(0, 0, 10, 10);
15
16 // This test verifies that ImageCapture.setOptions() rejects if any passed
17 // option is unsupported or outside its allowed range.
18 var makePromiseTest = function(getOption) {
19 promise_test(function(t) {
20 var theMock = null;
21 var theCapturer = null;
22 return mockImageCaptureReady
23 .then(mock => {
24 theMock = mock;
25 theMock.capabilities().red_eye_reduction = 0;
26
27 var stream = canvas.captureStream();
28 return new ImageCapture(stream.getVideoTracks()[0]);
29 },
30 error => {
31 assert_unreached("Error creating MockImageCapture: " + error);
32 })
33 .then(capturer => {
34 theCapturer = capturer;
35 return capturer.getPhotoCapabilities();
36 })
37 .then(c => {
38 const options = getOption(theMock.capabilities());
39 return promise_rejects(t, "NotSupportedError",
40 theCapturer.setOptions(options));
41 });
42 });
43 };
44
45 const optionsGenerators = [
46 capabilities => ({ redEyeReduction : true }),
Reilly Grant (use Gerrit) 2017/05/15 18:27:49 here too
mcasas 2017/05/15 19:57:08 Done.
47 capabilities => ({ imageHeight : capabilities.height.max + 1 }),
48 capabilities => ({ imageHeight : capabilities.height.min - 1 }),
49 capabilities => ({ imageWidth : capabilities.width.max + 1 }),
50 capabilities => ({ imageWidth : capabilities.width.min - 1 }),
51 capabilities => ({ fillLightMode : "off" }),
52 ];
53
54 for (key in optionsGenerators) {
55 generate_tests(
56 makePromiseTest,
57 [[ 'ImageCapture.setOptions(options) rejects with bad options, #' + key,
58 optionsGenerators[key] ]]);
59 }
60
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698