| 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 assertRejectsWithError(promise, name, message) { | |
| 11 return promise.then(() => { | |
| 12 assert_unreached('expected promise to reject with ' + name); | |
| 13 }, error => { | |
| 14 assert_equals(error.name, name); | |
| 15 if (message !== undefined) | |
| 16 assert_equals(error.message, message); | |
| 17 }); | |
| 18 } | |
| 19 | |
| 20 function assertRejectsWithNotFoundError(promise) { | 10 function assertRejectsWithNotFoundError(promise) { |
| 21 return assertRejectsWithError(promise, 'NotFoundError'); | 11 return assertRejectsWithError(promise, 'NotFoundError'); |
| 22 } | 12 } |
| 23 | 13 |
| 24 function assertRejectsWithNotOpenError(promise) { | 14 function assertRejectsWithNotOpenError(promise) { |
| 25 return assertRejectsWithError( | 15 return assertRejectsWithError( |
| 26 promise, 'InvalidStateError', 'The device must be opened first.') | 16 promise, 'InvalidStateError', 'The device must be opened first.') |
| 27 } | 17 } |
| 28 | 18 |
| 29 function assertRejectsWithNotConfiguredError(promise) { | 19 function assertRejectsWithNotConfiguredError(promise) { |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 return navigator.usb.getDevices().then(devices => { | 652 return navigator.usb.getDevices().then(devices => { |
| 663 assert_equals(1, devices.length); | 653 assert_equals(1, devices.length); |
| 664 let device = devices[0]; | 654 let device = devices[0]; |
| 665 return device.open().then(() => { | 655 return device.open().then(() => { |
| 666 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); | 656 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); |
| 667 return assertRejectsWithNotFoundError(device.reset()); | 657 return assertRejectsWithNotFoundError(device.reset()); |
| 668 }); | 658 }); |
| 669 }); | 659 }); |
| 670 }, 'resetDevice rejects when called on a disconnected device'); | 660 }, 'resetDevice rejects when called on a disconnected device'); |
| 671 </script> | 661 </script> |
| OLD | NEW |