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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Add README.md and more comments explaining the polyfill Created 3 years, 6 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <meta charset=utf-8> 4 <meta charset=utf-8>
5 <title>WebUSB IDL test</title> 5 <title>WebUSB IDL test</title>
6 <link rel="help" href="https://wicg.github.io/webusb/"> 6 <link rel="help" href="https://wicg.github.io/webusb/">
7 <script src=/resources/testharness.js></script> 7 <script src=/resources/testharness.js></script>
8 <script src=/resources/testharnessreport.js></script> 8 <script src=/resources/testharnessreport.js></script>
9 <script src=/resources/WebIDLParser.js></script> 9 <script src=/resources/WebIDLParser.js></script>
10 <script src=/resources/idlharness.js></script> 10 <script src=/resources/idlharness.js></script>
11 <script src=resources/fake-devices.js></script>
12 <script src=resources/usb-helpers.js></script>
11 </head> 13 </head>
12 <body> 14 <body>
13 <script> 15 <script>
14 'use strict'; 16 'use strict';
15 17
18 // Object instances used by the IDL test.
19 var usbDevice;
20 var usbConfiguration;
21 var usbInterface;
22 var usbAlternateInterface;
23 var usbEndpoint;
24 var usbConnectionEvent;
25
16 promise_test(async () => { 26 promise_test(async () => {
17 let response = await fetch('/interfaces/webusb.idl'); 27 let response = await fetch('/interfaces/webusb.idl');
18 let idl_text = response.text(); 28 let idl_text = await response.text();
19 let idl_array = new IdlArray(); 29 let idl_array = new IdlArray();
20 idl_array.add_idls(idl_text); 30 idl_array.add_idls(idl_text);
21 31
22 // Untested IDL interfaces 32 // Untested IDL interfaces
23 idl_array.add_untested_idls('interface Event {};'); 33 idl_array.add_untested_idls('interface Event {};');
24 idl_array.add_untested_idls('interface EventHandler {};'); 34 idl_array.add_untested_idls('interface EventHandler {};');
25 idl_array.add_untested_idls('dictionary EventInit {};'); 35 idl_array.add_untested_idls('dictionary EventInit {};');
26 idl_array.add_untested_idls('interface EventTarget {};'); 36 idl_array.add_untested_idls('interface EventTarget {};');
27 idl_array.add_untested_idls('interface Navigator {};'); 37 idl_array.add_untested_idls('interface Navigator {};');
28 38
29 idl_array.add_objects({ 39 idl_array.add_objects({
30 Navigator: ['navigator'], 40 Navigator: ['navigator'],
31 USB: ['navigator.usb'], 41 USB: ['navigator.usb'],
32 USBInTransferResult: ['new USBInTransferResult("ok")'], 42 USBInTransferResult: ['new USBInTransferResult("ok")'],
33 USBOutTransferResult: ['new USBOutTransferResult("ok")'], 43 USBOutTransferResult: ['new USBOutTransferResult("ok")'],
34 USBIsochronousInTransferResult: ['new USBIsochronousInTransferResult([ ])'], 44 USBIsochronousInTransferResult: ['new USBIsochronousInTransferResult([ ])'],
35 USBIsochronousOutTransferResult: ['new USBIsochronousOutTransferResult ([])'], 45 USBIsochronousOutTransferResult: ['new USBIsochronousOutTransferResult ([])'],
36 USBIsochronousInTransferPacket: ['new USBIsochronousInTransferPacket(" ok")'], 46 USBIsochronousInTransferPacket: ['new USBIsochronousInTransferPacket(" ok")'],
37 USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket ("ok")'], 47 USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket ("ok")'],
38 }); 48 });
39 49
50 // If the WebUSB Test API is available then interfaces requiring an
51 // instance of USBDevice can be tested.
52 try {
53 await navigator.usb.test.initialize();
54 navigator.usb.test.addFakeDevice(fakeDeviceInit);
55 usbDevice = await new Promise(resolve => {
56 navigator.usb.onconnect = e => resolve(e.device);
57 });
58
59 usbConfiguration = usbDevice.configurations[0];
60 usbInterface = usbConfiguration.interfaces[0];
61 usbAlternateInterface = usbInterface.alternates[0];
62 usbEndpoint = usbAlternateInterface.endpoints[0];
63 usbConnectionEvent =
64 new USBConnectionEvent('connect', { device: usbDevice })
65
66 idl_array.add_objects({
67 USBAlternateInterface: ['usbAlternateInterface'],
68 USBConfiguration: ['usbConfiguration'],
69 USBConnectionEvent: ['usbConnectionEvent'],
70 USBDevice: ['usbDevice'],
71 USBEndpoint: ['usbEndpoint'],
72 USBInterface: ['usbInterface']
73 });
74 } catch (e) {
75 // Do nothing.
76 }
77
40 idl_array.test(); 78 idl_array.test();
41 }, 'WebUSB IDL test'); 79 }, 'WebUSB IDL test');
42 </script> 80 </script>
43 </body> 81 </body>
44 </html> 82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698