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

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

Issue 1754543003: Add WebUSB layout tests for device disconnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses rockot@'s nits. 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 // 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
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
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 }
OLDNEW
« no previous file with comments | « content/renderer/usb/web_usb_device_impl.cc ('k') | third_party/WebKit/LayoutTests/usb/usb.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698