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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/usbDevice.html

Issue 1912223002: Make new WebUSB implementation more resilient to garbage collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased again. Created 4 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/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 17 matching lines...) Expand all
28 assert_equals(1, devices.length); 28 assert_equals(1, devices.length);
29 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); 29 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]);
30 return assertRejectsWithNotFoundError(devices[0].open()); 30 return assertRejectsWithNotFoundError(devices[0].open());
31 }); 31 });
32 }, 'open rejects when called on a disconnected device'); 32 }, 'open rejects when called on a disconnected device');
33 33
34 usb_test(usb => { 34 usb_test(usb => {
35 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]); 35 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
36 return navigator.usb.getDevices().then(devices => { 36 return navigator.usb.getDevices().then(devices => {
37 assert_equals(1, devices.length); 37 assert_equals(1, devices.length);
38 let promise = devices[0].open();
39 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]);
40 return assertRejectsWithNotFoundError(promise)
41 .then(() => runGarbageCollection());
42 });
43 }, 'open rejects when device disconnected during call');
44
45 usb_test(usb => {
46 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
47 return navigator.usb.getDevices().then(devices => {
48 assert_equals(1, devices.length);
38 let device = devices[0]; 49 let device = devices[0];
39 assert_false(device.opened); 50 assert_false(device.opened);
40 return device.open().then(() => { 51 return device.open().then(() => {
41 assert_true(device.opened); 52 assert_true(device.opened);
42 return device.close().then(() => { 53 return device.close().then(() => {
43 assert_false(device.opened); 54 assert_false(device.opened);
44 }); 55 });
45 }); 56 });
46 }); 57 }).then(() => runGarbageCollection());
47 }, 'a device can be opened and closed'); 58 }, 'a device can be opened and closed');
48 59
49 usb_test(usb => { 60 usb_test(usb => {
50 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]); 61 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
51 return navigator.usb.getDevices().then(devices => { 62 return navigator.usb.getDevices().then(devices => {
52 assert_equals(1, devices.length); 63 assert_equals(1, devices.length);
53 let device = devices[0]; 64 let device = devices[0];
54 return device.open() 65 return device.open()
55 .then(() => device.open()) 66 .then(() => device.open())
56 .then(() => device.open()) 67 .then(() => device.open())
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 return navigator.usb.getDevices().then(devices => { 756 return navigator.usb.getDevices().then(devices => {
746 assert_equals(1, devices.length); 757 assert_equals(1, devices.length);
747 let device = devices[0]; 758 let device = devices[0];
748 return device.open().then(() => { 759 return device.open().then(() => {
749 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]); 760 usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]);
750 return assertRejectsWithNotFoundError(device.reset()); 761 return assertRejectsWithNotFoundError(device.reset());
751 }); 762 });
752 }); 763 });
753 }, 'resetDevice rejects when called on a disconnected device'); 764 }, 'resetDevice rejects when called on a disconnected device');
754 </script> 765 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | third_party/WebKit/Source/modules/webusb/USB.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698