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

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

Issue 1470823002: Enable builtin Mojo JS modules in layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-testing
Patch Set: oops, clumsy Created 4 years, 11 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698