| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: | 3 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: |
| 4 // https://crbug.com/509058. | 4 // https://crbug.com/509058. |
| 5 function callWithKeyDown(functionCalledOnKeyPress) { | 5 function callWithKeyDown(functionCalledOnKeyPress) { |
| 6 return new Promise(resolve => { | 6 return new Promise(resolve => { |
| 7 function onKeyPress() { | 7 function onKeyPress() { |
| 8 document.removeEventListener('keypress', onKeyPress, false); | 8 document.removeEventListener('keypress', onKeyPress, false); |
| 9 resolve(functionCalledOnKeyPress()); | 9 resolve(functionCalledOnKeyPress()); |
| 10 } | 10 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 devices_added: this.addedDevices_, | 364 devices_added: this.addedDevices_, |
| 365 devices_removed: this.removedDevices_ | 365 devices_removed: this.removedDevices_ |
| 366 } | 366 } |
| 367 }); | 367 }); |
| 368 this.addedDevices_ = []; | 368 this.addedDevices_ = []; |
| 369 this.removedDevices_ = []; | 369 this.removedDevices_ = []; |
| 370 } | 370 } |
| 371 | 371 |
| 372 getDevice(guid, pipe) { | 372 getDevice(guid, pipe) { |
| 373 let device = this.mockDevices_.get(guid); | 373 let device = this.mockDevices_.get(guid); |
| 374 if (device !== undefined) { | 374 if (device === undefined) { |
| 375 mojo.core.close(pipe); |
| 376 } else { |
| 375 var mock = new MockDevice(device.info, pipe); | 377 var mock = new MockDevice(device.info, pipe); |
| 376 device.handles.push(mock); | 378 device.handles.push(mock); |
| 377 } | 379 } |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 | 382 |
| 381 class MockPermissionBubble | 383 class MockPermissionBubble |
| 382 extends permissionBubble.WebUsbPermissionBubble.stubClass { | 384 extends permissionBubble.WebUsbPermissionBubble.stubClass { |
| 383 constructor() { | 385 constructor() { |
| 384 super(); | 386 super(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 430 } |
| 429 | 431 |
| 430 function usb_test(func, name, properties) { | 432 function usb_test(func, name, properties) { |
| 431 mojo_test(mojo => usbMocks(mojo).then(usb => { | 433 mojo_test(mojo => usbMocks(mojo).then(usb => { |
| 432 let result = Promise.resolve(func(usb)); | 434 let result = Promise.resolve(func(usb)); |
| 433 let cleanUp = () => usb.mockDeviceManager.reset(); | 435 let cleanUp = () => usb.mockDeviceManager.reset(); |
| 434 result.then(cleanUp, cleanUp); | 436 result.then(cleanUp, cleanUp); |
| 435 return result; | 437 return result; |
| 436 }), name, properties); | 438 }), name, properties); |
| 437 } | 439 } |
| OLD | NEW |