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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js

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 'use strict'; 1 'use strict';
2 2
3 function assertRejectsWithError(promise, name, message) {
4 return promise.then(() => {
5 assert_unreached('expected promise to reject with ' + name);
6 }, error => {
7 assert_equals(error.name, name);
8 if (message !== undefined)
9 assert_equals(error.message, message);
10 });
11 }
12
3 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: 13 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js:
4 // https://crbug.com/509058. 14 // https://crbug.com/509058.
5 function callWithKeyDown(functionCalledOnKeyPress) { 15 function callWithKeyDown(functionCalledOnKeyPress) {
6 return new Promise(resolve => { 16 return new Promise(resolve => {
7 function onKeyPress() { 17 function onKeyPress() {
8 document.removeEventListener('keypress', onKeyPress, false); 18 document.removeEventListener('keypress', onKeyPress, false);
9 resolve(functionCalledOnKeyPress()); 19 resolve(functionCalledOnKeyPress());
10 } 20 }
11 document.addEventListener('keypress', onKeyPress, false); 21 document.addEventListener('keypress', onKeyPress, false);
12 22
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 458 }
449 459
450 function usb_test(func, name, properties) { 460 function usb_test(func, name, properties) {
451 mojo_test(mojo => usbMocks(mojo).then(usb => { 461 mojo_test(mojo => usbMocks(mojo).then(usb => {
452 let result = Promise.resolve(func(usb)); 462 let result = Promise.resolve(func(usb));
453 let cleanUp = () => usb.mockDeviceManager.reset(); 463 let cleanUp = () => usb.mockDeviceManager.reset();
454 result.then(cleanUp, cleanUp); 464 result.then(cleanUp, cleanUp);
455 return result; 465 return result;
456 }), name, properties); 466 }), name, properties);
457 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698