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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/resources/mojo-helpers.js

Issue 1367853002: Move GeolocationDispatcher into blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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();
11 11
12 return function(name, deps, factory) { 12 return function(name, deps, factory) {
13 let promise = moduleCache.get(name); 13 let promise = moduleCache.get(name);
14 if (promise === undefined) { 14 if (promise === undefined) {
15 // This promise must be cached as mojo.define will only call the factory 15 // This promise must be cached as mojo.define will only call the factory
16 // function the first time the module is defined. 16 // function the first time the module is defined.
17 promise = new Promise(resolve => { 17 promise = new Promise(resolve => {
18 mojo.define(name, deps, (...modules) => { 18 mojo.define(name, deps, (...modules) => {
19 let result = factory(...modules); 19 let result = factory(...modules);
20 resolve(result); 20 resolve(result);
21 return result; 21 return result;
22 }); 22 });
23 }); 23 });
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', [
Michael van Ouwerkerk 2016/05/04 13:52:16 Is there no way to avoid duplicating this whole fi
Sam McNally 2016/05/05 11:50:23 Removed this duplicate.
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/frame_service_registry', 34 'content/public/renderer/frame_service_registry',
35 'content/public/renderer/service_registry', 35 'content/public/renderer/service_registry',
36 ], (core, router, support, frameServiceRegistry, serviceRegistry) => { 36 ], (core, router, support, frameServiceRegistry, serviceRegistry) => {
37 let tearDown = () => { 37 let tearDown = () => {
38 frameServiceRegistry.clearServiceOverridesForTesting(); 38 frameServiceRegistry.clearServiceOverridesForTesting();
39 serviceRegistry.clearServiceOverridesForTesting(); 39 serviceRegistry.clearServiceOverridesForTesting();
40 }; 40 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 let buffer, handles; 83 let buffer, handles;
84 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); 84 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0));
85 if (result !== mojo.core.RESULT_OK) { 85 if (result !== mojo.core.RESULT_OK) {
86 reject(result); 86 reject(result);
87 return; 87 return;
88 } 88 }
89 resolve({ buffer, handles }); 89 resolve({ buffer, handles });
90 }); 90 });
91 }); 91 });
92 }; 92 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698