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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/usb-connection-event.html

Issue 2816663002: Ensure tests don't depend on fake devices being added synchronously (Closed)
Patch Set: Define FakeUSBDevice class only once Created 3 years, 8 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 <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> 6 <script src="resources/webusb-test.js"></script>
7 <script> 7 <script>
8 'use strict'; 8 'use strict';
9 9
10 usb_test(() => { 10 usb_test(() => {
11 navigator.usb.test.addFakeDevice(fakeDeviceInit); 11 return getFakeDevice().then(({ device }) => {
12 12 let evt = new USBConnectionEvent('connect', { device: device });
13 return navigator.usb.getDevices().then(devices => {
14 assert_equals(devices.length, 1);
15 let evt = new USBConnectionEvent('connect', { device: devices[0] });
16 assert_equals(evt.type, 'connect'); 13 assert_equals(evt.type, 'connect');
17 assert_equals(evt.device, devices[0]); 14 assert_equals(evt.device, device);
18 }); 15 });
19 }, 'Can construct a USBConnectionEvent with a device'); 16 }, 'Can construct a USBConnectionEvent with a device');
20 17
21 test(t => { 18 test(t => {
22 try { 19 try {
23 new USBConnectionEvent('connect', { device: null }); 20 new USBConnectionEvent('connect', { device: null });
24 assert_unreached('expected TypeError'); 21 assert_unreached('expected TypeError');
25 } catch (err) { 22 } catch (err) {
26 assert_true(err instanceof TypeError); 23 assert_true(err instanceof TypeError);
27 } 24 }
28 25
29 try { 26 try {
30 new USBConnectionEvent('connect', {}) 27 new USBConnectionEvent('connect', {})
31 assert_unreached('expected TypeError'); 28 assert_unreached('expected TypeError');
32 } catch (err) { 29 } catch (err) {
33 assert_true(err instanceof TypeError); 30 assert_true(err instanceof TypeError);
34 } 31 }
35 }, 'Cannot construct a USBConnectionEvent without a device'); 32 }, 'Cannot construct a USBConnectionEvent without a device');
36 </script> 33 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/usb.html ('k') | third_party/WebKit/LayoutTests/usb/usbDevice.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698