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/fake-devices.js"></script> | 4 <script src="resources/fake-devices.js"></script> |
5 <script src="resources/usb-helpers.js"></script> | 5 <script src="resources/usb-helpers.js"></script> |
6 <script src="resources/webusb-test.js"></script> | |
7 <script> | 6 <script> |
8 'use strict'; | 7 'use strict'; |
9 | 8 |
10 // Returns a promise that is resolved when the next USBConnectionEvent of the | 9 // Returns a promise that is resolved when the next USBConnectionEvent of the |
11 // given type is received. | 10 // given type is received. |
12 function connectionEventPromise(eventType) { | 11 function connectionEventPromise(eventType) { |
13 return new Promise(resolve => { | 12 return new Promise(resolve => { |
14 let eventHandler = e => { | 13 let eventHandler = e => { |
15 assert_true(e instanceof USBConnectionEvent); | 14 assert_true(e instanceof USBConnectionEvent); |
16 navigator.usb.removeEventListener(eventType, eventHandler); | 15 navigator.usb.removeEventListener(eventType, eventHandler); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 assert_equals(removedDevice, device); | 136 assert_equals(removedDevice, device); |
138 return removedDevice.open().then(() => { | 137 return removedDevice.open().then(() => { |
139 assert_unreachable('should not be able to open a disconnected device'); | 138 assert_unreachable('should not be able to open a disconnected device'); |
140 }, error => { | 139 }, error => { |
141 assert_equals(error.code, DOMException.NOT_FOUND_ERR); | 140 assert_equals(error.code, DOMException.NOT_FOUND_ERR); |
142 }); | 141 }); |
143 }); | 142 }); |
144 }); | 143 }); |
145 }, 'ondisconnect event is triggered by removing a device'); | 144 }, 'ondisconnect event is triggered by removing a device'); |
146 </script> | 145 </script> |
OLD | NEW |