Commit 558a2864 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

mojo: blink: Use new bindings names in blink

Mojo JS Lite Bindings were recently renamed to align with the new C++
names. This CL changes usage of the old names with the new ones. See
bug for more details.

Bug: 968369
Change-Id: I7ffbbf85e508fc81fc93b8f21a95e35f27699375
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1705831Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarAyu Ishii <ayui@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678571}
parent 01769212
......@@ -173,9 +173,6 @@ mojom("mojom_platform") {
"//url/mojom:url_mojom_origin",
]
# TODO(https://crbug.com/968369): Change to use new names.
use_old_js_lite_bindings_names = true
# iOS doesn't use and must not depend on //media
if (!is_ios) {
public_deps += [
......@@ -243,9 +240,6 @@ mojom("android_mojo_bindings") {
public_deps += [ "//ui/gfx/geometry/mojo" ]
}
# TODO(https://crbug.com/968369): Change to use new names.
use_old_js_lite_bindings_names = true
export_class_attribute = "BLINK_COMMON_EXPORT"
export_define = "BLINK_COMMON_IMPLEMENTATION=1"
export_header = "third_party/blink/public/common/common_export.h"
......@@ -491,7 +485,4 @@ mojom("authenticator_test_mojo_bindings") {
# Don't scramble message IDs so they are redistributable to external tests.
scramble_message_ids = false
# TODO(https://crbug.com/968369): Change to use new names.
use_old_js_lite_bindings_names = true
}
......@@ -19,11 +19,23 @@ let interceptor = (async function() {
return load.then(intercept);
})();
class SmsProvider {
// Fake implementation of blink.mojom.SmsReceiver.
class FakeSmsReceiverImpl {
constructor() {
this.returnValues = {}
}
bindHandleToMojoReceiver(handle) {
this.mojoReceiver_ = new blink.mojom.SmsReceiverReceiver(this);
this.mojoReceiver_.$.bindHandle(handle);
}
pushReturnValuesForTesting(callName, returnValues) {
this.returnValues[callName] = this.returnValues[callName] || [];
this.returnValues[callName].push(returnValues);
return this;
}
receive(timeout) {
let call = this.returnValues.receive.shift();
if (!call) {
......@@ -31,12 +43,6 @@ class SmsProvider {
}
return call(timeout);
}
pushReturnValues(callName, returnValues) {
this.returnValues[callName] = this.returnValues[callName] || [];
this.returnValues[callName].push(returnValues);
return this;
}
}
function receive(timeout, callback) {
......@@ -46,8 +52,8 @@ function receive(timeout, callback) {
function expect(call) {
return {
async andReturn(callback) {
let provider = await interceptor;
provider.pushReturnValues(call.name, callback);
let smsReceiverImpl = await interceptor;
smsReceiverImpl.pushReturnValuesForTesting(call.name, callback);
}
}
}
......@@ -55,13 +61,12 @@ function expect(call) {
const Status = {};
function intercept() {
let provider = new SmsProvider();
let smsReceiverImpl = new FakeSmsReceiverImpl();
let interceptor = new MojoInterfaceInterceptor(
blink.mojom.SmsReceiver.$interfaceName);
interceptor.oninterfacerequest = (e) => {
let impl = new blink.mojom.SmsReceiver(provider);
impl.$.bindHandle(e.handle);
smsReceiverImpl.bindHandleToMojoReceiver(e.handle);
}
interceptor.start();
......@@ -69,5 +74,5 @@ function intercept() {
Status.kSuccess = blink.mojom.SmsStatus.kSuccess;
Status.kTimeout = blink.mojom.SmsStatus.kTimeout;
return provider;
return smsReceiverImpl;
}
......@@ -16,6 +16,11 @@ class MockCredentialManager {
this.reset();
}
bindHandleToReceiver(handle) {
this.receiver_ = new blink.mojom.CredentialManagerReceiver(this);
this.receiver_.$.bindHandle(handle);
}
constructCredentialInfo_(type, id, password, name, icon) {
return {
type: type,
......@@ -68,6 +73,11 @@ class MockAuthenticator {
this.reset();
}
bindHandleToReceiver(handle) {
this.receiver_ = new blink.mojom.AuthenticatorReceiver(this);
this.receiver_.$.bindHandle(handle);
}
// Returns a MakeCredentialResponse to the client.
async makeCredential(options) {
var response = null;
......@@ -185,11 +195,9 @@ var mockCredentialManager = new MockCredentialManager();
setDocumentInterfaceBrokerOverrides({
getAuthenticator: request => {
var authenticator = new blink.mojom.Authenticator(mockAuthenticator);
authenticator.$.bindHandle(request.handle);
mockAuthenticator.bindHandleToReceiver(request.handle);
},
getCredentialManager: request => {
var credentialManager = new blink.mojom.CredentialManager(mockCredentialManager);
credentialManager.$.bindHandle(request.handle);
mockCredentialManager.bindHandleToReceiver(request.handle);
}
});
......@@ -53,11 +53,11 @@ class VirtualAuthenticator {
class VirtualAuthenticatorManager {
constructor() {
const docBrokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy(
const docBrokerRemote = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.getDocumentInterfaceBrokerHandle());
this.virtualAuthenticatorManager_ = new blink.test.mojom.VirtualAuthenticatorManagerProxy;
docBrokerProxy.getVirtualAuthenticatorManager(
this.virtualAuthenticatorManager_.$.createRequest());
this.virtualAuthenticatorManager_ = new blink.test.mojom.VirtualAuthenticatorManagerRemote;
docBrokerRemote.getVirtualAuthenticatorManager(
this.virtualAuthenticatorManager_.$.bindNewPipeAndPassReceiver());
}
async createAuthenticator(options = {}) {
......
......@@ -18,25 +18,25 @@ promise_test(async t => {
const frameHostTestImpl = new blink.mojom.FrameHostTestInterfaceCallbackRouter;
frameHostTestImpl.getName.addListener(() => ({ name: 'TestFrameHostTestImpl' }));
const brokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy(
const broker = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.getDocumentInterfaceBrokerHandle());
const testInterfaceProxyBeforeOverride = new blink.mojom.FrameHostTestInterfaceProxy;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyBeforeOverride.$.createRequest());
const testInterfaceBeforeOverride = new blink.mojom.FrameHostTestInterfaceRemote;
broker.getFrameHostTestInterface(testInterfaceBeforeOverride.$.bindNewPipeAndPassReceiver());
setDocumentInterfaceBrokerOverrides({ getFrameHostTestInterface: request => {
frameHostTestImpl.$.bindHandle(request.handle);
}});
const testInterfaceProxyAfterOverride = new blink.mojom.FrameHostTestInterfaceProxy;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyAfterOverride.$.createRequest());
const testInterfaceAfterOverride = new blink.mojom.FrameHostTestInterfaceRemote;
broker.getFrameHostTestInterface(testInterfaceAfterOverride.$.bindNewPipeAndPassReceiver());
// Verify that RenderFrameHostImpl's implementation gets called without an override
let reply = await testInterfaceProxyBeforeOverride.getName();
let reply = await testInterfaceBeforeOverride.getName();
assert_equals(reply.name, 'RenderFrameHostImpl');
// Verify that the test implementation gets called after the override
reply = await testInterfaceProxyAfterOverride.getName();
reply = await testInterfaceAfterOverride.getName();
assert_equals(reply.name, 'TestFrameHostTestImpl');
},
'Appropriate DocumentInterfaceBroker implementations are called before and after overriding');
......
......@@ -16,14 +16,15 @@
*/
function setDocumentInterfaceBrokerOverrides(overrides) {
const {handle0, handle1} = Mojo.createMessagePipe();
const realBrokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy(
const realBrokerRemote = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.replaceDocumentInterfaceBrokerForTesting(handle0));
for (const method of Object.keys(overrides)) {
realBrokerProxy[method] = overrides[method];
realBrokerRemote[method] = overrides[method];
}
// Use the real broker (with overrides) as the implementation of the JS-side broker
const testBrokerBinding = new blink.mojom.DocumentInterfaceBroker(realBrokerProxy);
testBrokerBinding.$.bindHandle(handle1);
const testBrokerReceiver =
new blink.mojom.DocumentInterfaceBrokerReceiver(realBrokerRemote);
testBrokerReceiver.$.bindHandle(handle1);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment