OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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/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 add_completion_callback(() => { | 37 if (window.add_completion_callback) { |
38 frameServiceRegistry.clearServiceOverridesForTesting(); | 38 add_completion_callback(() => { |
39 serviceRegistry.clearServiceOverridesForTesting(); | 39 frameServiceRegistry.clearServiceOverridesForTesting(); |
40 }); | 40 serviceRegistry.clearServiceOverridesForTesting(); |
| 41 }); |
| 42 } |
41 | 43 |
42 return { | 44 return { |
43 core, | 45 core, |
44 router, | 46 router, |
45 support, | 47 support, |
46 frameServiceRegistry, | 48 frameServiceRegistry, |
47 serviceRegistry, | 49 serviceRegistry, |
48 }; | 50 }; |
49 }); | 51 }); |
50 | 52 |
(...skipping 29 matching lines...) Expand all Loading... |
80 let buffer, handles; | 82 let buffer, handles; |
81 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); | 83 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); |
82 if (result !== mojo.core.RESULT_OK) { | 84 if (result !== mojo.core.RESULT_OK) { |
83 reject(result); | 85 reject(result); |
84 return; | 86 return; |
85 } | 87 } |
86 resolve({ buffer, handles }); | 88 resolve({ buffer, handles }); |
87 }); | 89 }); |
88 }); | 90 }); |
89 }; | 91 }; |
OLD | NEW |