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

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

Issue 1827473002: Make the process-wide ServiceRegistry available to JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/mojo-helpers.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 setChosenDevice(deviceInfo) { 415 setChosenDevice(deviceInfo) {
416 this.chosenDeviceInfo_ = deviceInfo; 416 this.chosenDeviceInfo_ = deviceInfo;
417 } 417 }
418 418
419 getPermission(deviceFilters) { 419 getPermission(deviceFilters) {
420 return Promise.resolve({ result: this.chosenDeviceInfo_ }); 420 return Promise.resolve({ result: this.chosenDeviceInfo_ });
421 } 421 }
422 } 422 }
423 423
424 let mockDeviceManager = new MockDeviceManager; 424 let mockDeviceManager = new MockDeviceManager;
425 mojo.serviceRegistry.addServiceOverrideForTesting( 425 mojo.frameServiceRegistry.addServiceOverrideForTesting(
426 deviceManager.DeviceManager.name, 426 deviceManager.DeviceManager.name,
427 pipe => { 427 pipe => {
428 mockDeviceManager.bindToPipe(pipe); 428 mockDeviceManager.bindToPipe(pipe);
429 }); 429 });
430 430
431 let mockChooserService = new MockChooserService; 431 let mockChooserService = new MockChooserService;
432 mojo.serviceRegistry.addServiceOverrideForTesting( 432 mojo.frameServiceRegistry.addServiceOverrideForTesting(
433 chooserService.ChooserService.name, 433 chooserService.ChooserService.name,
434 pipe => { 434 pipe => {
435 mockChooserService.bindToPipe(pipe); 435 mockChooserService.bindToPipe(pipe);
436 }); 436 });
437 437
438 return fakeUsbDevices().then(fakeDevices => Promise.resolve({ 438 return fakeUsbDevices().then(fakeDevices => Promise.resolve({
439 DeviceManager: deviceManager.DeviceManager, 439 DeviceManager: deviceManager.DeviceManager,
440 Device: device.Device, 440 Device: device.Device,
441 mockDeviceManager: mockDeviceManager, 441 mockDeviceManager: mockDeviceManager,
442 mockChooserService: mockChooserService, 442 mockChooserService: mockChooserService,
443 fakeDevices: fakeDevices, 443 fakeDevices: fakeDevices,
444 assertDeviceInfoEquals: assertDeviceInfoEquals, 444 assertDeviceInfoEquals: assertDeviceInfoEquals,
445 assertConfigurationInfoEquals: assertConfigurationInfoEquals, 445 assertConfigurationInfoEquals: assertConfigurationInfoEquals,
446 })); 446 }));
447 }); 447 });
448 } 448 }
449 449
450 function usb_test(func, name, properties) { 450 function usb_test(func, name, properties) {
451 mojo_test(mojo => usbMocks(mojo).then(usb => { 451 mojo_test(mojo => usbMocks(mojo).then(usb => {
452 let result = Promise.resolve(func(usb)); 452 let result = Promise.resolve(func(usb));
453 let cleanUp = () => usb.mockDeviceManager.reset(); 453 let cleanUp = () => usb.mockDeviceManager.reset();
454 result.then(cleanUp, cleanUp); 454 result.then(cleanUp, cleanUp);
455 return result; 455 return result;
456 }), name, properties); 456 }), name, properties);
457 } 457 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/mojo-helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698