1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * This URL is defined in content/public/test/test_mojo_app.cc. It identifies
8 * content_shell's out-of-process Mojo test app.
10 var TEST_APP_URL = 'system:content_mojo_test';
14 'mojo/application/public/interfaces/shell.mojom',
15 'mojo/public/js/core',
16 'mojo/public/js/router',
17 'mojo/services/network/public/interfaces/url_loader.mojom',
18 'content/public/renderer/service_provider',
19 'content/public/test/test_mojo_service.mojom',
20 ], function(shellMojom, core, router, urlMojom, serviceRegistry, testMojom) {
22 var connectToService = function(serviceProvider, iface) {
23 var pipe = core.createMessagePipe();
24 var service = new iface.proxyClass(new router.Router(pipe.handle0));
25 serviceProvider.connectToService(iface.name, pipe.handle1);
30 domAutomationController.setAutomationId(0);
31 var shellPipe = serviceRegistry.connectToService(shellMojom.Shell.name);
32 var shell = new shellMojom.Shell.proxyClass(new router.Router(shellPipe));
33 var urlRequest = new urlMojom.URLRequest({ url: TEST_APP_URL });
34 shell.connectToApplication(urlRequest,
36 var test = connectToService(services, testMojom.TestMojoService);
37 test.getRequestorURL().then(function(response) {
38 // The requestor URL seen by the app should be localhost because the
39 // connection comes from this script hosted on the test server.
40 domAutomationController.send(response.url == 'http://127.0.0.1/');
43 function (exposedServices) {});