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

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

Issue 1836203002: Change the battery-status layout tests to use JS mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 16 matching lines...) Expand all
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 let tearDown = () => {
38 frameServiceRegistry.clearServiceOverridesForTesting(); 38 frameServiceRegistry.clearServiceOverridesForTesting();
39 serviceRegistry.clearServiceOverridesForTesting(); 39 serviceRegistry.clearServiceOverridesForTesting();
40 }); 40 };
41 addEventListener('unload', tearDown);
42 if (window.add_completion_callback)
43 add_completion_callback(tearDown);
41 44
42 return { 45 return {
43 core, 46 core,
44 router, 47 router,
45 support, 48 support,
46 frameServiceRegistry, 49 frameServiceRegistry,
47 serviceRegistry, 50 serviceRegistry,
48 }; 51 };
49 }); 52 });
50 53
(...skipping 29 matching lines...) Expand all
80 let buffer, handles; 83 let buffer, handles;
81 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0)); 84 ({ result, buffer, handles } = mojo.core.readMessage(pipe, 0));
82 if (result !== mojo.core.RESULT_OK) { 85 if (result !== mojo.core.RESULT_OK) {
83 reject(result); 86 reject(result);
84 return; 87 return;
85 } 88 }
86 resolve({ buffer, handles }); 89 resolve({ buffer, handles });
87 }); 90 });
88 }); 91 });
89 }; 92 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698