| 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 15 matching lines...) Expand all Loading... |
| 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/frame_interfaces', | 34 'content/public/renderer/frame_interfaces', |
| 35 'content/public/renderer/interfaces', | 35 'content/public/renderer/interfaces', |
| 36 ], (core, router, support, frameInterfaces, interfaces) => { | 36 'content/shell/renderer/layout_test/frame_interface_registry', |
| 37 'content/shell/renderer/layout_test/interface_registry', |
| 38 ], (core, router, support, frameInterfaces, interfaces, frameInterfaceRegistry, |
| 39 interfaceRegistry) => { |
| 37 let tearDown = () => { | 40 let tearDown = () => { |
| 38 frameInterfaces.clearInterfaceOverridesForTesting(); | 41 frameInterfaces.clearInterfaceOverridesForTesting(); |
| 39 interfaces.clearInterfaceOverridesForTesting(); | 42 interfaces.clearInterfaceOverridesForTesting(); |
| 40 }; | 43 }; |
| 41 addEventListener('unload', tearDown); | 44 addEventListener('unload', tearDown); |
| 42 if (window.add_completion_callback) | 45 if (window.add_completion_callback) |
| 43 add_completion_callback(tearDown); | 46 add_completion_callback(tearDown); |
| 44 | 47 |
| 45 return { | 48 return { |
| 46 core, | 49 core, |
| 47 router, | 50 router, |
| 48 support, | 51 support, |
| 49 frameInterfaces, | 52 frameInterfaces, |
| 53 frameInterfaceRegistry, |
| 50 interfaces, | 54 interfaces, |
| 55 interfaceRegistry, |
| 51 }; | 56 }; |
| 52 }); | 57 }); |
| 53 | 58 |
| 54 // Returns a promise to an object that exposes common Mojo module interfaces. | 59 // Returns a promise to an object that exposes common Mojo module interfaces. |
| 55 // Additional modules to load can be specified in the |modules| parameter. The | 60 // Additional modules to load can be specified in the |modules| parameter. The |
| 56 // result will contain them, in the same order, in the |modules| field. | 61 // result will contain them, in the same order, in the |modules| field. |
| 57 function loadMojoModules(name, modules = []) { | 62 function loadMojoModules(name, modules = []) { |
| 58 return define('Mojo modules: ' + name, | 63 return define('Mojo modules: ' + name, |
| 59 [ 'Mojo Helpers' ].concat(modules), | 64 [ 'Mojo Helpers' ].concat(modules), |
| 60 (mojo, ...rest) => { | 65 (mojo, ...rest) => { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 let buffer, handles; | 88 let buffer, handles; |
| 84 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); | 89 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); |
| 85 if (result !== mojo.core.RESULT_OK) { | 90 if (result !== mojo.core.RESULT_OK) { |
| 86 reject(result); | 91 reject(result); |
| 87 return; | 92 return; |
| 88 } | 93 } |
| 89 resolve({ buffer, handles }); | 94 resolve({ buffer, handles }); |
| 90 }); | 95 }); |
| 91 }); | 96 }); |
| 92 }; | 97 }; |
| OLD | NEW |