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") { ...@@ -173,9 +173,6 @@ mojom("mojom_platform") {
"//url/mojom:url_mojom_origin", "//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 # iOS doesn't use and must not depend on //media
if (!is_ios) { if (!is_ios) {
public_deps += [ public_deps += [
...@@ -243,9 +240,6 @@ mojom("android_mojo_bindings") { ...@@ -243,9 +240,6 @@ mojom("android_mojo_bindings") {
public_deps += [ "//ui/gfx/geometry/mojo" ] 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_class_attribute = "BLINK_COMMON_EXPORT"
export_define = "BLINK_COMMON_IMPLEMENTATION=1" export_define = "BLINK_COMMON_IMPLEMENTATION=1"
export_header = "third_party/blink/public/common/common_export.h" export_header = "third_party/blink/public/common/common_export.h"
...@@ -491,7 +485,4 @@ mojom("authenticator_test_mojo_bindings") { ...@@ -491,7 +485,4 @@ mojom("authenticator_test_mojo_bindings") {
# Don't scramble message IDs so they are redistributable to external tests. # Don't scramble message IDs so they are redistributable to external tests.
scramble_message_ids = false 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() { ...@@ -19,11 +19,23 @@ let interceptor = (async function() {
return load.then(intercept); return load.then(intercept);
})(); })();
class SmsProvider { // Fake implementation of blink.mojom.SmsReceiver.
class FakeSmsReceiverImpl {
constructor() { constructor() {
this.returnValues = {} 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) { receive(timeout) {
let call = this.returnValues.receive.shift(); let call = this.returnValues.receive.shift();
if (!call) { if (!call) {
...@@ -31,12 +43,6 @@ class SmsProvider { ...@@ -31,12 +43,6 @@ class SmsProvider {
} }
return call(timeout); return call(timeout);
} }
pushReturnValues(callName, returnValues) {
this.returnValues[callName] = this.returnValues[callName] || [];
this.returnValues[callName].push(returnValues);
return this;
}
} }
function receive(timeout, callback) { function receive(timeout, callback) {
...@@ -46,8 +52,8 @@ function receive(timeout, callback) { ...@@ -46,8 +52,8 @@ function receive(timeout, callback) {
function expect(call) { function expect(call) {
return { return {
async andReturn(callback) { async andReturn(callback) {
let provider = await interceptor; let smsReceiverImpl = await interceptor;
provider.pushReturnValues(call.name, callback); smsReceiverImpl.pushReturnValuesForTesting(call.name, callback);
} }
} }
} }
...@@ -55,13 +61,12 @@ function expect(call) { ...@@ -55,13 +61,12 @@ function expect(call) {
const Status = {}; const Status = {};
function intercept() { function intercept() {
let provider = new SmsProvider(); let smsReceiverImpl = new FakeSmsReceiverImpl();
let interceptor = new MojoInterfaceInterceptor( let interceptor = new MojoInterfaceInterceptor(
blink.mojom.SmsReceiver.$interfaceName); blink.mojom.SmsReceiver.$interfaceName);
interceptor.oninterfacerequest = (e) => { interceptor.oninterfacerequest = (e) => {
let impl = new blink.mojom.SmsReceiver(provider); smsReceiverImpl.bindHandleToMojoReceiver(e.handle);
impl.$.bindHandle(e.handle);
} }
interceptor.start(); interceptor.start();
...@@ -69,5 +74,5 @@ function intercept() { ...@@ -69,5 +74,5 @@ function intercept() {
Status.kSuccess = blink.mojom.SmsStatus.kSuccess; Status.kSuccess = blink.mojom.SmsStatus.kSuccess;
Status.kTimeout = blink.mojom.SmsStatus.kTimeout; Status.kTimeout = blink.mojom.SmsStatus.kTimeout;
return provider; return smsReceiverImpl;
} }
...@@ -16,8 +16,13 @@ class MockCredentialManager { ...@@ -16,8 +16,13 @@ class MockCredentialManager {
this.reset(); this.reset();
} }
bindHandleToReceiver(handle) {
this.receiver_ = new blink.mojom.CredentialManagerReceiver(this);
this.receiver_.$.bindHandle(handle);
}
constructCredentialInfo_(type, id, password, name, icon) { constructCredentialInfo_(type, id, password, name, icon) {
return { return {
type: type, type: type,
id: stringToMojoString16(id), id: stringToMojoString16(id),
name: stringToMojoString16(name), name: stringToMojoString16(name),
...@@ -68,6 +73,11 @@ class MockAuthenticator { ...@@ -68,6 +73,11 @@ class MockAuthenticator {
this.reset(); this.reset();
} }
bindHandleToReceiver(handle) {
this.receiver_ = new blink.mojom.AuthenticatorReceiver(this);
this.receiver_.$.bindHandle(handle);
}
// Returns a MakeCredentialResponse to the client. // Returns a MakeCredentialResponse to the client.
async makeCredential(options) { async makeCredential(options) {
var response = null; var response = null;
...@@ -185,11 +195,9 @@ var mockCredentialManager = new MockCredentialManager(); ...@@ -185,11 +195,9 @@ var mockCredentialManager = new MockCredentialManager();
setDocumentInterfaceBrokerOverrides({ setDocumentInterfaceBrokerOverrides({
getAuthenticator: request => { getAuthenticator: request => {
var authenticator = new blink.mojom.Authenticator(mockAuthenticator); mockAuthenticator.bindHandleToReceiver(request.handle);
authenticator.$.bindHandle(request.handle);
}, },
getCredentialManager: request => { getCredentialManager: request => {
var credentialManager = new blink.mojom.CredentialManager(mockCredentialManager); mockCredentialManager.bindHandleToReceiver(request.handle);
credentialManager.$.bindHandle(request.handle);
} }
}); });
...@@ -53,11 +53,11 @@ class VirtualAuthenticator { ...@@ -53,11 +53,11 @@ class VirtualAuthenticator {
class VirtualAuthenticatorManager { class VirtualAuthenticatorManager {
constructor() { constructor() {
const docBrokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy( const docBrokerRemote = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.getDocumentInterfaceBrokerHandle()); Mojo.getDocumentInterfaceBrokerHandle());
this.virtualAuthenticatorManager_ = new blink.test.mojom.VirtualAuthenticatorManagerProxy; this.virtualAuthenticatorManager_ = new blink.test.mojom.VirtualAuthenticatorManagerRemote;
docBrokerProxy.getVirtualAuthenticatorManager( docBrokerRemote.getVirtualAuthenticatorManager(
this.virtualAuthenticatorManager_.$.createRequest()); this.virtualAuthenticatorManager_.$.bindNewPipeAndPassReceiver());
} }
async createAuthenticator(options = {}) { async createAuthenticator(options = {}) {
......
...@@ -18,25 +18,25 @@ promise_test(async t => { ...@@ -18,25 +18,25 @@ promise_test(async t => {
const frameHostTestImpl = new blink.mojom.FrameHostTestInterfaceCallbackRouter; const frameHostTestImpl = new blink.mojom.FrameHostTestInterfaceCallbackRouter;
frameHostTestImpl.getName.addListener(() => ({ name: 'TestFrameHostTestImpl' })); frameHostTestImpl.getName.addListener(() => ({ name: 'TestFrameHostTestImpl' }));
const brokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy( const broker = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.getDocumentInterfaceBrokerHandle()); Mojo.getDocumentInterfaceBrokerHandle());
const testInterfaceProxyBeforeOverride = new blink.mojom.FrameHostTestInterfaceProxy; const testInterfaceBeforeOverride = new blink.mojom.FrameHostTestInterfaceRemote;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyBeforeOverride.$.createRequest()); broker.getFrameHostTestInterface(testInterfaceBeforeOverride.$.bindNewPipeAndPassReceiver());
setDocumentInterfaceBrokerOverrides({ getFrameHostTestInterface: request => { setDocumentInterfaceBrokerOverrides({ getFrameHostTestInterface: request => {
frameHostTestImpl.$.bindHandle(request.handle); frameHostTestImpl.$.bindHandle(request.handle);
}}); }});
const testInterfaceProxyAfterOverride = new blink.mojom.FrameHostTestInterfaceProxy; const testInterfaceAfterOverride = new blink.mojom.FrameHostTestInterfaceRemote;
brokerProxy.getFrameHostTestInterface(testInterfaceProxyAfterOverride.$.createRequest()); broker.getFrameHostTestInterface(testInterfaceAfterOverride.$.bindNewPipeAndPassReceiver());
// Verify that RenderFrameHostImpl's implementation gets called without an override // 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'); assert_equals(reply.name, 'RenderFrameHostImpl');
// Verify that the test implementation gets called after the override // Verify that the test implementation gets called after the override
reply = await testInterfaceProxyAfterOverride.getName(); reply = await testInterfaceAfterOverride.getName();
assert_equals(reply.name, 'TestFrameHostTestImpl'); assert_equals(reply.name, 'TestFrameHostTestImpl');
}, },
'Appropriate DocumentInterfaceBroker implementations are called before and after overriding'); 'Appropriate DocumentInterfaceBroker implementations are called before and after overriding');
......
...@@ -16,14 +16,15 @@ ...@@ -16,14 +16,15 @@
*/ */
function setDocumentInterfaceBrokerOverrides(overrides) { function setDocumentInterfaceBrokerOverrides(overrides) {
const {handle0, handle1} = Mojo.createMessagePipe(); const {handle0, handle1} = Mojo.createMessagePipe();
const realBrokerProxy = new blink.mojom.DocumentInterfaceBrokerProxy( const realBrokerRemote = new blink.mojom.DocumentInterfaceBrokerRemote(
Mojo.replaceDocumentInterfaceBrokerForTesting(handle0)); Mojo.replaceDocumentInterfaceBrokerForTesting(handle0));
for (const method of Object.keys(overrides)) { 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 // Use the real broker (with overrides) as the implementation of the JS-side broker
const testBrokerBinding = new blink.mojom.DocumentInterfaceBroker(realBrokerProxy); const testBrokerReceiver =
testBrokerBinding.$.bindHandle(handle1); 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