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

Side by Side Diff: third_party/WebKit/LayoutTests/resources/mojo-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
OLDNEW
1 /* 1 /*
2 * mojo-helpers contains extensions to testharness.js useful for consuming 2 * mojo-helpers contains extensions to testharness.js useful for consuming
3 * and mocking Mojo services directly within test code. 3 * and mocking Mojo services directly within test code.
4 */ 4 */
5 'use strict'; 5 'use strict';
6 6
7 // Fix up the global window.define, since all baked-in Mojo modules expect to 7 // Fix up the global window.define, since all baked-in Mojo modules expect to
8 // find it there. This define() also returns a promise to the module. 8 // find it there. This define() also returns a promise to the module.
9 let define = (function(){ 9 let define = (function(){
10 let moduleCache = new Map(); 10 let moduleCache = new Map();
(...skipping 13 matching lines...) Expand all
24 moduleCache.set(name, promise); 24 moduleCache.set(name, promise);
25 } 25 }
26 return promise; 26 return promise;
27 } 27 }
28 })(); 28 })();
29 29
30 define('Mojo Helpers', [ 30 define('Mojo Helpers', [
31 'mojo/public/js/core', 31 'mojo/public/js/core',
32 'mojo/public/js/router', 32 'mojo/public/js/router',
33 'mojo/public/js/support', 33 'mojo/public/js/support',
34 'content/public/renderer/service_provider' 34 'content/public/renderer/frame_service_registry',
35 ], (core, router, support, serviceProvider) => { 35 'content/public/renderer/service_registry',
36 ], (core, router, support, frameServiceRegistry, serviceRegistry) => {
36 add_completion_callback(() => { 37 add_completion_callback(() => {
37 serviceProvider.clearServiceOverridesForTesting(); 38 frameServiceRegistry.clearServiceOverridesForTesting();
39 serviceRegistry.clearServiceOverridesForTesting();
38 }); 40 });
39 41
40 return { 42 return {
41 core: core, 43 core,
42 router: router, 44 router,
43 support: support, 45 support,
44 46 frameServiceRegistry,
45 // |serviceProvider| is a bit of a misnomer. It should probably be 47 serviceRegistry,
46 // called |serviceRegistry|, so let's call it that here.
47 serviceRegistry: serviceProvider,
48 }; 48 };
49 }); 49 });
50 50
51 // Returns a promise to an object that exposes common Mojo module interfaces. 51 // Returns a promise to an object that exposes common Mojo module interfaces.
52 // Additional modules to load can be specified in the |modules| parameter. The 52 // Additional modules to load can be specified in the |modules| parameter. The
53 // result will contain them, in the same order, in the |modules| field. 53 // result will contain them, in the same order, in the |modules| field.
54 function loadMojoModules(name, modules = []) { 54 function loadMojoModules(name, modules = []) {
55 return define('Mojo modules: ' + name, 55 return define('Mojo modules: ' + name,
56 [ 'Mojo Helpers' ].concat(modules), 56 [ 'Mojo Helpers' ].concat(modules),
57 (mojo, ...rest) => { 57 (mojo, ...rest) => {
(...skipping 22 matching lines...) Expand all
80 let buffer, handles; 80 let buffer, handles;
81 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); 81 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0));
82 if (result !== mojo.core.RESULT_OK) { 82 if (result !== mojo.core.RESULT_OK) {
83 reject(result); 83 reject(result);
84 return; 84 return;
85 } 85 }
86 resolve({ buffer, handles }); 86 resolve({ buffer, handles });
87 }); 87 });
88 }); 88 });
89 }; 89 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698