usbDevice_reset-manual.https.html (1528B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title></title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="resources/manual.js"></script> 9 </head> 10 <body> 11 <p> 12 These tests require a USB device to be connected. 13 </p> 14 <script> 15 const kGetDescriptorRequest = 0x06; 16 const kDeviceDescriptorType = 0x01; 17 const kDeviceDescriptorLength = 18; 18 19 manual_usb_test(async (t, device) => { 20 await device.open(); 21 t.add_cleanup(async () => { 22 await device.close(); 23 }); 24 25 // This test exercises the behavior that the device remains open when it 26 // is reset. If the device changes its properties too drastically when 27 // reset it may appear to disconnect instead. 28 await device.reset(); 29 30 // Read the device descriptor in order to validate that communication 31 // with the device is still possible after a reset. 32 const result = await device.controlTransferIn({ 33 requestType: 'standard', 34 recipient: 'device', 35 request: kGetDescriptorRequest, 36 value: kDeviceDescriptorType << 8, 37 index: 0, 38 }, kDeviceDescriptorLength); 39 40 assert_equals(result.status, 'ok', 'transfer status'); 41 assert_equals( 42 result.data.byteLength, kDeviceDescriptorLength, 'transfer length'); 43 }, 'reset() does not disconnect the device'); 44 </script> 45 </body> 46 </html>