Adds support for embedViewManagerClient() to IFrame.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/912183002
This commit is contained in:
Hans Muller
2015-02-10 17:09:22 -08:00
parent 86ae400a55
commit 8716bf6a98
3 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1 @@
success

View File

@@ -0,0 +1,34 @@
<html>
<import src="/gen/mojo/public/interfaces/application/shell.mojom.sky" as="shellMojom" />
<import src="/gen/mojo/public/sky/connection.sky" as="connection" />
<import src="/gen/mojo/public/sky/core.sky" as="core" />
<import src="/gen/mojo/services/public/sky/shell.sky" as="shellJS" />
<import src="/gen/services/js/test/echo_service.mojom.sky" as="echoServiceMojom" />
<import src="/gen/mojo/services/view_manager/public/interfaces/view_manager.mojom.sky" as="ViewManager">
<import src="/gen/mojo/services/input_events/public/interfaces/input_events.mojom.sky" as="InputEvents"/>
<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
<iframe></iframe>
<script>
var shellHandle = internals.passShellProxyHandle();
var shellProxy = connection.bindHandleToProxy(shellHandle, shellMojom.Shell);
var shell = new shellJS.Shell(shellProxy);
// The vmcApp provides ViewManagerClient and EchoService.
var vmcURL = "http://127.0.0.1:8000/sky/tests/services/resources/iframe-vmc.js"
var vmcApp = shell.connectToApplication(vmcURL);
// The Promise returned by the vmcApp's echoString() method will not
// resolve until the vmcApp's onEmbed() method runs.
var echoService = vmcApp.requestService(echoServiceMojom.EchoService);
echoService.echoString("success").then(function(response) {
internals.notifyTestComplete(response.value);
});
// Using internals.connectToService here, instead of just connecting
// with vmcApp, because we just need a MessagePipe handle (not a proxy).
var vmcService = internals.connectToService(vmcURL, ViewManager.ViewManagerClient.name);
document.querySelector("iframe").embedViewManagerClient(vmcService);
</script>
</html>

View File

@@ -0,0 +1,36 @@
#!mojo mojo:js_content_handler
define("main", [
"console",
"mojo/public/js/bindings",
"mojo/services/public/js/application",
"mojo/services/view_manager/public/interfaces/view_manager.mojom",
"services/js/test/echo_service.mojom",
], function(console, bindings, application, viewManagerMojom, echoServiceMojom) {
const Application = application.Application;
const ViewManagerClient = viewManagerMojom.ViewManagerClient;
const EchoService = echoServiceMojom.EchoService;
var serviceImpl;
var success = new Promise(function(resolve) {
serviceImpl = {
onEmbed: function() {
resolve({value: "success"});
},
echoString: function(s) {
return success;
},
}
});
class IFrameVMCApp extends Application {
acceptConnection(initiatorURL, initiatorServiceExchange) {
var factory = function() { return serviceImpl; }
initiatorServiceExchange.provideService(ViewManagerClient, factory);
initiatorServiceExchange.provideService(EchoService, factory);
}
}
return IFrameVMCApp;
});