OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * mojo-helpers contains extensions to testharness.js useful for consuming |
| 3 * and mocking Mojo services directly within test code. |
| 4 */ |
| 5 'use strict'; |
| 6 |
| 7 // Runs a promise_test which depends on the Mojo system API modules available to |
| 8 // all layout tests. The test implementation function is called with an Object |
| 9 // that exposes common Mojo module interfaces. |
| 10 function mojo_test(func, name, properties) { |
| 11 // Fix up the global window.define, since all baked-in Mojo modules expect to |
| 12 // find it there. |
| 13 window.define = mojo.define; |
| 14 |
| 15 promise_test(() => { |
| 16 return new Promise((resolve, reject) => { |
| 17 define('Mojo layout test module: ' + name, [ |
| 18 'mojo/public/js/core', |
| 19 'mojo/public/js/router', |
| 20 'content/public/renderer/service_provider', |
| 21 ], (core, router, serviceProvider) => { |
| 22 try { |
| 23 resolve(func({ |
| 24 core: core, |
| 25 router: router, |
| 26 |
| 27 // |serviceProvider| is a bit of a misnomer. It should probably be |
| 28 // called |serviceRegistry|, so let's call it that here. |
| 29 serviceRegistry: serviceProvider, |
| 30 })); |
| 31 } catch (e) { |
| 32 reject(e); |
| 33 } |
| 34 }); |
| 35 }); |
| 36 }, name, properties); |
| 37 } |
OLD | NEW |