blob: 146e0e85c8e876509ee9375fdcdbf5c69b171ee7 [file] [log] [blame]
mcasasadc09e42017-05-03 00:39:131<!DOCTYPE html>
2<html>
3<head>
4 <meta charset=utf-8>
5 <title>Image Capture IDL test</title>
6 <link rel="help" href="https://w3c.github.io/mediacapture-image">
7 <link rel="idl" href="https://w3c.github.io/mediacapture-image/#idl-index">
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 <script src="/resources/WebIDLParser.js"></script>
11 <script src="/resources/idlharness.js"></script>
12</head>
13<body>
14 <canvas id='canvas' width=10 height=10/>
15
16 <pre id="untested_idl" style="display: none">
17 interface Event {};
18 interface EventHandler {};
19 interface EventTarget {};
20 interface MediaStreamTrack {};
21 </pre>
22 <pre id="idl" style="display: none">
23 // https://w3c.github.io/mediacapture-image
24
25 [Constructor(MediaStreamTrack videoTrack)]
26 interface ImageCapture {
27 Promise<Blob> takePhoto(optional PhotoSettings photoSettings);
28 Promise<PhotoCapabilities> getPhotoCapabilities();
29
30 Promise<ImageBitmap> grabFrame();
31
32 readonly attribute MediaStreamTrack track;
33 };
34
35 interface PhotoCapabilities {
36 readonly attribute RedEyeReduction redEyeReduction;
37 readonly attribute MediaSettingsRange imageHeight;
38 readonly attribute MediaSettingsRange imageWidth;
39 readonly attribute FrozenArray<FillLightMode> fillLightMode;
40 };
41
42 dictionary PhotoSettings {
43 FillLightMode fillLightMode;
44 double imageHeight;
45 double imageWidth;
46 boolean redEyeReduction;
47 };
48
49 interface MediaSettingsRange {
50 readonly attribute double max;
51 readonly attribute double min;
52 readonly attribute double step;
53 };
54
55 enum RedEyeReduction {
56 "never",
57 "always",
58 "controllable",
59 };
60
61 enum FillLightMode {
62 "auto",
63 "off",
64 "flash",
65 };
66
67 // Partial dictionaries are unsupported, see
68 // https://github.com/w3c/testharness.js/issues/84
69
70 partial dictionary MediaTrackSupportedConstraints {
71 boolean whiteBalanceMode = true;
72 boolean exposureMode = true;
73 boolean focusMode = true;
74 boolean pointsOfInterest = true;
75
76 boolean exposureCompensation = true;
77 boolean colorTemperature = true;
78 boolean iso = true;
79
80 boolean brightness = true;
81 boolean contrast = true;
82 boolean saturation = true;
83 boolean sharpness = true;
84 boolean zoom = true;
85 boolean torch = true;
86 };
87
88 partial dictionary MediaTrackCapabilities {
89 sequence<DOMString> whiteBalanceMode;
90 sequence<DOMString> exposureMode;
91 sequence<DOMString> focusMode;
92
93 MediaSettingsRange exposureCompensation;
94 MediaSettingsRange colorTemperature;
95 MediaSettingsRange iso;
96
97 MediaSettingsRange brightness;
98 MediaSettingsRange contrast;
99 MediaSettingsRange saturation;
100 MediaSettingsRange sharpness;
101
102 MediaSettingsRange zoom;
103
104 boolean torch;
105 };
106
107 partial dictionary MediaTrackConstraintSet {
108 ConstrainDOMString whiteBalanceMode;
109 ConstrainDOMString exposureMode;
110 ConstrainDOMString focusMode;
111 ConstrainPoint2D pointsOfInterest;
112
113 ConstrainDouble exposureCompensation;
114 ConstrainDouble colorTemperature;
115 ConstrainDouble iso;
116
117 ConstrainDouble brightness;
118 ConstrainDouble contrast;
119 ConstrainDouble saturation;
120 ConstrainDouble sharpness;
121
122 ConstrainDouble zoom;
123
124 ConstrainBoolean torch;
125 };
126
127 partial dictionary MediaTrackSettings {
128 DOMString whiteBalanceMode;
129 DOMString exposureMode;
130 DOMString focusMode;
131 sequence<Point2D> pointsOfInterest;
132
133 double exposureCompensation;
134 double colorTemperature;
135 double iso;
136
137 double brightness;
138 double contrast;
139 double saturation;
140 double sharpness;
141
142 double zoom;
143
144 boolean torch;
145 };
146
147 dictionary ConstrainPoint2DParameters {
148 sequence<Point2D> exact;
149 sequence<Point2D> ideal;
150 };
151
152 typedef (sequence<Point2D> or ConstrainPoint2DParameters) ConstrainPoint2D;
153
154 enum MeteringMode {
155 "none",
156 "manual",
157 "single-shot",
158 "continuous"
159 };
160
161 dictionary Point2D {
162 double x = 0.0;
163 double y = 0.0;
164 };
165
166 </pre>
167 <script>
168 var canvas = document.getElementById('canvas');
169 var context = canvas.getContext("2d");
170 context.fillStyle = "red";
171 context.fillRect(0, 0, 10, 10);
172 var track = canvas.captureStream().getVideoTracks()[0];
173
174 var idl_array = new IdlArray();
175 idl_array.add_untested_idls(
176 document.getElementById("untested_idl").textContent);
177 idl_array.add_idls(document.getElementById("idl").textContent);
178 idl_array.add_objects({
179 ImageCapturer : [new ImageCapture(track)]
180 });
181 idl_array.test();
182 </script>
183 <div id="log"></div>
184</body>
185</html>