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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/idlharness.html

Issue 2752383002: Add idlharness.js tests for WebUSB. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/usb/idlharness-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset=utf-8>
5 <title>WebUSB IDL test</title>
6 <link rel="help" href="https://wicg.github.io/webusb/">
7 <script src="../resources/testharness.js"></script>
8 <script src="../resources/testharnessreport.js"></script>
9 <script src="../resources/WebIDLParser.js"></script>
10 <script src="../resources/idlharness.js"></script>
11 <script src="../resources/mojo-helpers.js"></script>
12 <script src="resources/fake-devices.js"></script>
13 <script src="resources/usb-helpers.js"></script>
14 </head>
15 <body>
16 <script type="text/plain" id="untested">
17 interface Event {};
18 interface EventHandler {};
19 interface EventTarget {};
20 interface Navigator {};
21 </script>
22 <script type="text/plain" id="tested">
23 // Copied from https://wicg.github.io/webusb/#idl-index minus the
24 // definitions related to Permissions API integration which is unstable.
25
26 dictionary USBDeviceFilter {
27 unsigned short vendorId;
28 unsigned short productId;
29 octet classCode;
30 octet subclassCode;
31 octet protocolCode;
32 DOMString serialNumber;
33 };
34
35 dictionary USBDeviceRequestOptions {
36 required sequence<USBDeviceFilter> filters;
37 };
38
39 interface USB : EventTarget {
40 attribute EventHandler onconnect;
41 attribute EventHandler ondisconnect;
42 Promise<sequence<USBDevice>> getDevices();
43 Promise<USBDevice> requestDevice(USBDeviceRequestOptions options);
44 };
45
46 [SecureContext]
47 partial interface Navigator {
48 [SameObject] readonly attribute USB usb;
49 };
50
51 dictionary USBConnectionEventInit : EventInit {
52 required USBDevice device;
53 };
54
55 [Constructor(DOMString type, USBConnectionEventInit eventInitDict)]
56 interface USBConnectionEvent : Event {
57 [SameObject] readonly attribute USBDevice device;
58 };
59
60 interface USBDevice {
61 readonly attribute octet usbVersionMajor;
62 readonly attribute octet usbVersionMinor;
63 readonly attribute octet usbVersionSubminor;
64 readonly attribute octet deviceClass;
65 readonly attribute octet deviceSubclass;
66 readonly attribute octet deviceProtocol;
67 readonly attribute unsigned short vendorId;
68 readonly attribute unsigned short productId;
69 readonly attribute octet deviceVersionMajor;
70 readonly attribute octet deviceVersionMinor;
71 readonly attribute octet deviceVersionSubminor;
72 readonly attribute DOMString? manufacturerName;
73 readonly attribute DOMString? productName;
74 readonly attribute DOMString? serialNumber;
75 readonly attribute USBConfiguration? configuration;
76 readonly attribute FrozenArray<USBConfiguration> configurations;
77 readonly attribute boolean opened;
78 Promise<void> open();
79 Promise<void> close();
80 Promise<void> selectConfiguration(octet configurationValue);
81 Promise<void> claimInterface(octet interfaceNumber);
82 Promise<void> releaseInterface(octet interfaceNumber);
83 Promise<void> selectAlternateInterface(octet interfaceNumber, octet alte rnateSetting);
84 Promise<USBInTransferResult> controlTransferIn(USBControlTransferParamet ers setup, unsigned short length);
85 Promise<USBOutTransferResult> controlTransferOut(USBControlTransferParam eters setup, optional BufferSource data);
86 Promise<void> clearHalt(USBDirection direction, octet endpointNumber);
87 Promise<USBInTransferResult> transferIn(octet endpointNumber, unsigned l ong length);
88 Promise<USBOutTransferResult> transferOut(octet endpointNumber, BufferSo urce data);
89 Promise<USBIsochronousInTransferResult> isochronousTransferIn(octet endp ointNumber, sequence<unsigned long> packetLengths);
90 Promise<USBIsochronousOutTransferResult> isochronousTransferOut(octet en dpointNumber, BufferSource data, sequence<unsigned long> packetLengths);
91 Promise<void> reset();
92 };
93
94 enum USBRequestType {
95 "standard",
96 "class",
97 "vendor"
98 };
99
100 enum USBRecipient {
101 "device",
102 "interface",
103 "endpoint",
104 "other"
105 };
106
107 enum USBTransferStatus {
108 "ok",
109 "stall",
110 "babble"
111 };
112
113 dictionary USBControlTransferParameters {
114 required USBRequestType requestType;
115 required USBRecipient recipient;
116 required octet request;
117 required unsigned short value;
118 required unsigned short index;
119 };
120
121 [Constructor(USBTransferStatus status, optional DataView? data)]
122 interface USBInTransferResult {
123 readonly attribute DataView? data;
124 readonly attribute USBTransferStatus status;
125 };
126
127 [Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)]
128 interface USBOutTransferResult {
129 readonly attribute unsigned long bytesWritten;
130 readonly attribute USBTransferStatus status;
131 };
132
133 [Constructor(USBTransferStatus status, optional DataView? data)]
134 interface USBIsochronousInTransferPacket {
135 readonly attribute DataView? data;
136 readonly attribute USBTransferStatus status;
137 };
138
139 [Constructor(sequence<USBIsochronousInTransferPacket> packets, optional Da taView? data)]
140 interface USBIsochronousInTransferResult {
141 readonly attribute DataView? data;
142 readonly attribute FrozenArray<USBIsochronousInTransferPacket> packets;
143 };
144
145 [Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)]
146 interface USBIsochronousOutTransferPacket {
147 readonly attribute unsigned long bytesWritten;
148 readonly attribute USBTransferStatus status;
149 };
150
151 [Constructor(sequence<USBIsochronousOutTransferPacket> packets)]
152 interface USBIsochronousOutTransferResult {
153 readonly attribute FrozenArray<USBIsochronousOutTransferPacket> packets;
154 };
155
156 [Constructor(USBDevice device, octet configurationValue)]
157 interface USBConfiguration {
158 readonly attribute octet configurationValue;
159 readonly attribute DOMString? configurationName;
160 readonly attribute FrozenArray<USBInterface> interfaces;
161 };
162
163 [Constructor(USBConfiguration configuration, octet interfaceNumber)]
164 interface USBInterface {
165 readonly attribute octet interfaceNumber;
166 readonly attribute USBAlternateInterface alternate;
167 readonly attribute FrozenArray<USBAlternateInterface> alternates;
168 readonly attribute boolean claimed;
169 };
170
171 [Constructor(USBInterface deviceInterface, octet alternateSetting)]
172 interface USBAlternateInterface {
173 readonly attribute octet alternateSetting;
174 readonly attribute octet interfaceClass;
175 readonly attribute octet interfaceSubclass;
176 readonly attribute octet interfaceProtocol;
177 readonly attribute DOMString? interfaceName;
178 readonly attribute FrozenArray<USBEndpoint> endpoints;
179 };
180
181 enum USBDirection {
182 "in",
183 "out"
184 };
185
186 enum USBEndpointType {
187 "bulk",
188 "interrupt",
189 "isochronous"
190 };
191
192 [Constructor(USBAlternateInterface alternate, octet endpointNumber, USBDir ection direction)]
193 interface USBEndpoint {
194 readonly attribute octet endpointNumber;
195 readonly attribute USBDirection direction;
196 readonly attribute USBEndpointType type;
197 readonly attribute unsigned long packetSize;
198 };
199 </script>
200 <script>
201 'use strict';
202
203 var idl_array = new IdlArray();
204 idl_array.add_untested_idls(document.querySelector('#untested').textConten t);
205 idl_array.add_idls(document.querySelector('#tested').textContent);
206 idl_array.add_objects({
207 Navigator: ['navigator'],
208 USB: ['navigator.usb'],
209 USBInTransferResult: ['new USBInTransferResult("ok")'],
210 USBOutTransferResult: ['new USBOutTransferResult("ok")'],
211 USBIsochronousInTransferResult: ['new USBIsochronousInTransferResult([]) '],
212 USBIsochronousOutTransferResult: ['new USBIsochronousOutTransferResult([ ])'],
213 USBIsochronousInTransferPacket: ['new USBIsochronousInTransferPacket("ok ")'],
214 USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket(" ok")']
215 });
216
217 // These types require a USBDevice instance to construct:
218 var usbAlternateInterface;
219 var usbConfiguration;
220 var usbConnectionEvent;
221 var usbDevice;
222 var usbEndpoint;
223 var usbInterface;
224
225 idl_array.add_objects({
226 USBAlternateInterface: ['usbAlternateInterface'],
227 USBConfiguration: ['usbConfiguration'],
228 USBConnectionEvent: ['usbConnectionEvent'],
229 USBDevice: ['usbDevice'],
230 USBEndpoint: ['usbEndpoint'],
231 USBInterface: ['usbInterface']
232 });
233
234 loadMojoModules('idlharness')
235 .then(mojo => usbMocks(mojo))
236 .then(usb => {
237 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
238 return navigator.usb.getDevices().then(devices => {
239 usbDevice = devices[0];
240 usbConfiguration = usbDevice.configurations[0];
241 usbInterface = usbConfiguration.interfaces[0];
242 usbAlternateInterface = usbInterface.alternates[0];
243 usbEndpoint = usbAlternateInterface.endpoints[0];
244 usbConnectionEvent =
245 new USBConnectionEvent('connect', { device: usbDevice });
246 });
247 })
248 .then(() => idl_array.test());
249 </script>
250 </body>
251 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/usb/idlharness-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698