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

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

Issue 1820173002: Close USB device connections when the page is hidden. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and fixed nit. Created 4 years, 9 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 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
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>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | third_party/WebKit/Source/modules/webusb/USBDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698