OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="../resources/mojo-helpers.js"></script> | 4 <script src="../resources/mojo-helpers.js"></script> |
5 <script src="resources/fake-devices.js"></script> | 5 <script src="resources/fake-devices.js"></script> |
6 <script src="resources/usb-helpers.js"></script> | 6 <script src="resources/usb-helpers.js"></script> |
7 <script> | 7 <script> |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 function assertRejectsWithNotFoundError(promise) { | 10 function assertRejectsWithNotFoundError(promise) { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 .then(() => Promise.all([ | 237 .then(() => Promise.all([ |
238 assertRejectsWithError( | 238 assertRejectsWithError( |
239 device.claimInterface(2), 'NotFoundError', message), | 239 device.claimInterface(2), 'NotFoundError', message), |
240 assertRejectsWithError( | 240 assertRejectsWithError( |
241 device.releaseInterface(2), 'NotFoundError', message), | 241 device.releaseInterface(2), 'NotFoundError', message), |
242 ])) | 242 ])) |
243 .then(() => device.close()); | 243 .then(() => device.close()); |
244 }); | 244 }); |
245 }, 'a non-existent interface cannot be claimed or released'); | 245 }, 'a non-existent interface cannot be claimed or released'); |
246 | 246 |
247 | |
248 usb_test(usb => { | 247 usb_test(usb => { |
249 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]); | 248 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]); |
250 return navigator.usb.getDevices().then(devices => { | 249 return navigator.usb.getDevices().then(devices => { |
251 assert_equals(1, devices.length); | 250 assert_equals(1, devices.length); |
252 var device = devices[0]; | 251 var device = devices[0]; |
253 return device.open() | 252 return device.open() |
254 .then(() => device.selectConfiguration(1)) | 253 .then(() => device.selectConfiguration(1)) |
255 .then(() => { | 254 .then(() => { |
256 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); | 255 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); |
257 return assertRejectsWithNotFoundError(device.claimInterface(0)); | 256 return assertRejectsWithNotFoundError(device.claimInterface(0)); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 return navigator.usb.getDevices().then(devices => { | 745 return navigator.usb.getDevices().then(devices => { |
747 assert_equals(1, devices.length); | 746 assert_equals(1, devices.length); |
748 let device = devices[0]; | 747 let device = devices[0]; |
749 return device.open().then(() => { | 748 return device.open().then(() => { |
750 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); | 749 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); |
751 return assertRejectsWithNotFoundError(device.reset()); | 750 return assertRejectsWithNotFoundError(device.reset()); |
752 }); | 751 }); |
753 }); | 752 }); |
754 }, 'resetDevice rejects when called on a disconnected device'); | 753 }, 'resetDevice rejects when called on a disconnected device'); |
755 </script> | 754 </script> |
OLD | NEW |