blob: 561b034a1ccaf21c083cf5b8d2bb40b3ef8a7946 [file] [log] [blame]
<body>
<script src="../resources/document-interface-broker-helpers.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="file:///gen/url/mojom/url.mojom-lite.js"></script>
<script src="file:///gen/third_party/blink/public/mojom/frame/frame_host_test_interface.mojom-lite.js"></script>
<script src="file:///gen/third_party/blink/public/mojom/frame/document_interface_broker.mojom-lite.js"></script>
<script>
'use strict';
promise_test(async t => {
// Create a test implementation of FrameHostTestInterface
const frameHostTestImpl = new blink.mojom.FrameHostTestInterfaceCallbackRouter;
frameHostTestImpl.getName.addListener(() => ({ name: 'TestFrameHostTestImpl' }));
const brokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy(
Mojo.getDocumentInterfaceBrokerHandle());
const testInterfaceProxyBeforeOverride = new blink.mojom.FrameHostTestInterfaceProxy;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyBeforeOverride.$.createRequest());
setDocumentInterfaceBrokerOverrides({ getFrameHostTestInterface: request => {
frameHostTestImpl.bindHandle(request.handle);
}});
const testInterfaceProxyAfterOverride = new blink.mojom.FrameHostTestInterfaceProxy;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyAfterOverride.$.createRequest());
// Verify that RenderFrameHostImpl's implementation gets called without an override
let reply = await testInterfaceProxyBeforeOverride.getName();
assert_equals(reply.name, 'RenderFrameHostImpl');
// Verify that the test implementation gets called after the override
reply = await testInterfaceProxyAfterOverride.getName();
assert_equals(reply.name, 'TestFrameHostTestImpl');
},
'Appropriate DocumentInterfaceBroker implementations are called before and after overriding');
</script>
</body>
</html>