Commit 6348fba7 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

mojo: Remove all code for old js bindings lite names

M77 has reached stable and there have been no major issues with the new
names.

Bug: 968369
Change-Id: I2de8132b9ac233a982c3e0d01bafd1c53e80d412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816251Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708877}
parent 98d7086a
...@@ -1034,7 +1034,6 @@ if (!is_ios) { ...@@ -1034,7 +1034,6 @@ if (!is_ios) {
":layout_test_data_mojo_bindings_lite", ":layout_test_data_mojo_bindings_lite",
"//content/shell:content_shell", "//content/shell:content_shell",
"//content/test:mojo_web_test_bindings_js_data_deps", "//content/test:mojo_web_test_bindings_js_data_deps",
"//content/test:mojo_web_test_old_names_bindings_js_data_deps",
"//content/shell:mojo_bindings_js_data_deps", "//content/shell:mojo_bindings_js_data_deps",
"//device/bluetooth/public/mojom:fake_bluetooth_interfaces_js_data_deps", "//device/bluetooth/public/mojom:fake_bluetooth_interfaces_js_data_deps",
"//device/vr/public/mojom:mojom_js_data_deps", "//device/vr/public/mojom:mojom_js_data_deps",
......
...@@ -303,7 +303,6 @@ jumbo_static_library("content_shell_lib") { ...@@ -303,7 +303,6 @@ jumbo_static_library("content_shell_lib") {
"//content/shell/test_runner:test_runner", "//content/shell/test_runner:test_runner",
"//content/test:content_test_mojo_bindings", "//content/test:content_test_mojo_bindings",
"//content/test:mojo_web_test_bindings", "//content/test:mojo_web_test_bindings",
"//content/test:mojo_web_test_old_names_bindings",
"//content/test:test_support", "//content/test:test_support",
"//content/test:web_test_support", "//content/test:web_test_support",
"//device/bluetooth", "//device/bluetooth",
......
...@@ -667,50 +667,17 @@ mojom("web_ui_test_mojo_bindings") { ...@@ -667,50 +667,17 @@ mojom("web_ui_test_mojo_bindings") {
] ]
} }
mojom("mojo_web_test_helper_test") {
testonly = true
sources = [
"data/mojo_web_test_helper_test.mojom",
]
# This mojom interface is exposed publicly to web tests which use
# prepackaged redistributable JS bindings. It is therefore not desirable to
# scramble these messages.
scramble_message_ids = false
}
mojom("mojo_web_test_bindings") { mojom("mojo_web_test_bindings") {
testonly = true testonly = true
sources = [ sources = [
"data/lite_js_test.mojom", "data/lite_js_test.mojom",
] "data/mojo_web_test_helper_test.mojom",
public_deps = [
":mojo_web_test_helper_test",
]
# This mojom interface is exposed publicly to web tests which use
# prepackaged redistributable JS bindings. It is therefore not desirable to
# scramble these messages.
scramble_message_ids = false
}
mojom("mojo_web_test_old_names_bindings") {
testonly = true
sources = [
"data/lite_js_old_names_test.mojom",
]
public_deps = [
":mojo_web_test_helper_test",
] ]
# This mojom interface is exposed publicly to web tests which use # This mojom interface is exposed publicly to web tests which use
# prepackaged redistributable JS bindings. It is therefore not desirable to # prepackaged redistributable JS bindings. It is therefore not desirable to
# scramble these messages. # scramble these messages.
scramble_message_ids = false scramble_message_ids = false
use_old_js_lite_bindings_names = true
} }
mojom("test_interfaces") { mojom("test_interfaces") {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module lite_js_old_names_test.mojom;
// Copy of lite_js_test.mojom that can be used in a separate target with a
// different value for "use_old_js_lite_bindings_names".
struct TestStruct {
int32 x;
const bool isValid = false;
};
union TestUnion {
int32 x;
TestStruct s;
};
// An interface whose definition covers various types of message signatures in
// order to exercise the lite JS mojom bindings.
interface TestMessageTarget {
// Zero arguments, no reply.
Poke();
// Zero-argument request, zero-argument reply.
Ping() => ();
// Request and reply both with arguments.
Repeat(string? message, array<int32>? numbers)
=> (string? message, array<int32>? numbers);
Flatten(array<TestStruct> values) => (array<int32> values);
FlattenUnions(array<TestUnion> unions) => (array<int32> x, array<int32> s);
RequestSubinterface(Subinterface& request, SubinterfaceClient client);
};
interface Subinterface {
Push(int32 value);
Flush();
};
interface SubinterfaceClient {
DidFlush(array<int32> values);
};
...@@ -13,40 +13,15 @@ mojom("test_mojom") { ...@@ -13,40 +13,15 @@ mojom("test_mojom") {
"module_b_1.test-mojom", "module_b_1.test-mojom",
"module_b_2.test-mojom", "module_b_2.test-mojom",
] ]
use_old_js_lite_bindings_names = false
}
mojom("test_old_names_mojom") {
testonly = true
sources = [
"module_a_old_names.test-mojom",
"module_b_1_old_names.test-mojom",
"module_b_2_old_names.test-mojom",
]
use_old_js_lite_bindings_names = true
} }
if (enable_mojom_closure_compile || closure_compile) { if (enable_mojom_closure_compile || closure_compile) {
js_library("compile_test_sources") {
sources = [
"compile_test.js",
]
deps = [
":test_mojom_js_library_for_compile",
":test_old_names_mojom_js_library_for_compile",
]
}
js_binary("compile_test") { js_binary("compile_test") {
outputs = [ outputs = [
"$target_gen_dir/compile_test.js", "$target_gen_dir/compile_test.js",
] ]
deps = [ deps = [
":compile_test_sources",
":test_mojom_js_library_for_compile", ":test_mojom_js_library_for_compile",
":test_old_names_mojom_js_library_for_compile",
] ]
closure_flags = strict_error_checking_closure_args + [ closure_flags = strict_error_checking_closure_args + [
"compilation_level=ADVANCED_OPTIMIZATIONS", "compilation_level=ADVANCED_OPTIMIZATIONS",
......
...@@ -2,13 +2,8 @@ ...@@ -2,13 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
goog.require('moduleBOldNames.TestInterface');
goog.require('moduleB.TestInterfaceRemote'); goog.require('moduleB.TestInterfaceRemote');
// This is not expected to do anything useful, but it must compile.
const proxy = moduleBOldNames.TestInterface.getProxy();
proxy.passA1({'q': '', 'r': '', 's': ''});
// This is not expected to do anything useful, but it must compile. // This is not expected to do anything useful, but it must compile.
const remote = moduleB.TestInterface.getRemote(); const remote = moduleB.TestInterface.getRemote();
remote.passA1({'q': '', 'r': '', 's': ''}); remote.passA1({'q': '', 'r': '', 's': ''});
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module module_a_old_names;
struct TestStructA1 {
string q;
string r;
string s;
};
struct TestStructA2 {
enum NestedEnum {
A,
B,
};
TestStructA1 ax;
TestStructA1 ay;
NestedEnum enumField;
};
enum ModuleEnum {
THIRD,
};
interface ParentInterface {
enum NestedEnum {
FIRST,
SECOND,
};
SomeMethod(NestedEnum value);
};
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module module_b_old_names;
struct TestStructB1 {
int32 x;
int32 y;
};
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module module_b_old_names;
import "mojo/public/js/test/module_a_old_names.test-mojom";
import "mojo/public/js/test/module_b_1_old_names.test-mojom";
struct TestStructB2 {
module_a_old_names.TestStructA1 a1;
module_a_old_names.TestStructA2 a2;
TestStructB2 b2;
};
interface TestInterface {
PassA1(module_a_old_names.TestStructA1 a1);
PassB1(TestStructB1 b1);
PassB2(TestStructB2 b2);
};
...@@ -18,21 +18,19 @@ ...@@ -18,21 +18,19 @@
{% endmacro %} {% endmacro %}
{% if generate_closure_exports -%} {% if generate_closure_exports -%}
{% if not use_old_names -%}
goog.provide('{{module.namespace}}.{{interface.name}}'); goog.provide('{{module.namespace}}.{{interface.name}}');
{% endif %} goog.provide('{{module.namespace}}.{{interface.name}}Receiver');
goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.receiver}}');
goog.provide('{{module.namespace}}.{{interface.name}}CallbackRouter'); goog.provide('{{module.namespace}}.{{interface.name}}CallbackRouter');
goog.provide('{{module.namespace}}.{{interface.name}}Interface'); goog.provide('{{module.namespace}}.{{interface.name}}Interface');
goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}'); goog.provide('{{module.namespace}}.{{interface.name}}Remote');
goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_receiver}}'); goog.provide('{{module.namespace}}.{{interface.name}}PendingReceiver');
{% endif %} {% endif %}
/** /**
* @implements {mojo.internal.interfaceSupport.PendingReceiver} * @implements {mojo.internal.interfaceSupport.PendingReceiver}
* @export * @export
*/ */
{{module.namespace}}.{{interface.name}}{{primitives_names.pending_receiver}} = class { {{module.namespace}}.{{interface.name}}PendingReceiver = class {
/** @param {!MojoHandle} handle */ /** @param {!MojoHandle} handle */
constructor(handle) { constructor(handle) {
/** @public {!MojoHandle} */ /** @public {!MojoHandle} */
...@@ -58,19 +56,19 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_ ...@@ -58,19 +56,19 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_
* @export * @export
* @implements { {{module.namespace}}.{{interface.name}}Interface } * @implements { {{module.namespace}}.{{interface.name}}Interface }
*/ */
{{module.namespace}}.{{interface.name}}{{primitives_names.remote}} = class { {{module.namespace}}.{{interface.name}}Remote = class {
/** @param {MojoHandle=} opt_handle */ /** @param {MojoHandle=} opt_handle */
constructor(opt_handle) { constructor(opt_handle) {
/** /**
* @private {!mojo.internal.interfaceSupport.InterfaceRemoteBase<!{{module.namespace}}.{{interface.name}}{{primitives_names.pending_receiver}}>} * @private {!mojo.internal.interfaceSupport.InterfaceRemoteBase<!{{module.namespace}}.{{interface.name}}PendingReceiver>}
*/ */
this.proxy = this.proxy =
new mojo.internal.interfaceSupport.InterfaceRemoteBase( new mojo.internal.interfaceSupport.InterfaceRemoteBase(
{{module.namespace}}.{{interface.name}}{{primitives_names.pending_receiver}}, {{module.namespace}}.{{interface.name}}PendingReceiver,
opt_handle); opt_handle);
/** /**
* @public {!mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper<!{{module.namespace}}.{{interface.name}}{{primitives_names.pending_receiver}}>} * @public {!mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper<!{{module.namespace}}.{{interface.name}}PendingReceiver>}
*/ */
this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy); this.$ = new mojo.internal.interfaceSupport.InterfaceRemoteBaseWrapper(this.proxy);
...@@ -115,17 +113,17 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_ ...@@ -115,17 +113,17 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_
* *
* @export * @export
*/ */
{{module.namespace}}.{{interface.name}}{{primitives_names.receiver}} = class { {{module.namespace}}.{{interface.name}}Receiver = class {
/** /**
* @param {!{{module.namespace}}.{{interface.name}}Interface } impl * @param {!{{module.namespace}}.{{interface.name}}Interface } impl
*/ */
constructor(impl) { constructor(impl) {
/** @private {!mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal<!{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}>} */ /** @private {!mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal<!{{module.namespace}}.{{interface.name}}Remote>} */
this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal( this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(
{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}); {{module.namespace}}.{{interface.name}}Remote);
/** /**
* @public {!mojo.internal.interfaceSupport.InterfaceReceiverHelper<!{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}>} * @public {!mojo.internal.interfaceSupport.InterfaceReceiverHelper<!{{module.namespace}}.{{interface.name}}Remote>}
*/ */
this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_); this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
...@@ -145,34 +143,8 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_ ...@@ -145,34 +143,8 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_
/** @public {!mojo.internal.interfaceSupport.ConnectionErrorEventRouter} */ /** @public {!mojo.internal.interfaceSupport.ConnectionErrorEventRouter} */
this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter(); this.onConnectionError = this.helper_internal_.getConnectionErrorEventRouter();
} }
{% if use_old_names -%}
/**
* Returns a proxy for this interface which sends messages to the browser.
* The browser must have an interface request binder registered for this
* interface and accessible to the calling document's frame.
*
* @return {!{{module.namespace}}.{{interface.name}}Proxy}
* @export
*/
static getProxy() {
let proxy = new {{module.namespace}}.{{interface.name}}Proxy;
Mojo.bindInterface('{{mojom_namespace}}.{{interface.name}}',
proxy.$.bindNewPipeAndPassReceiver().handle);
return proxy;
}
/**
* @return {!string}
*/
static get $interfaceName() {
return "{{mojom_namespace}}.{{interface.name}}";
}
{% endif %}
}; };
{% if not use_old_names -%}
/** /**
* @export * @export
*/ */
...@@ -200,8 +172,6 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_ ...@@ -200,8 +172,6 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_
} }
}; };
{% endif %}
{#--- Enums #} {#--- Enums #}
{% from "lite/enum_definition.tmpl" import enum_def with context %} {% from "lite/enum_definition.tmpl" import enum_def with context %}
{%- for enum in interface.enums %} {%- for enum in interface.enums %}
...@@ -221,10 +191,10 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_ ...@@ -221,10 +191,10 @@ goog.provide('{{module.namespace}}.{{interface.name}}{{primitives_names.pending_
{{module.namespace}}.{{interface.name}}CallbackRouter = class { {{module.namespace}}.{{interface.name}}CallbackRouter = class {
constructor() { constructor() {
this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal( this.helper_internal_ = new mojo.internal.interfaceSupport.InterfaceReceiverHelperInternal(
{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}); {{module.namespace}}.{{interface.name}}Remote);
/** /**
* @public {!mojo.internal.interfaceSupport.InterfaceReceiverHelper<!{{module.namespace}}.{{interface.name}}{{primitives_names.remote}}>} * @public {!mojo.internal.interfaceSupport.InterfaceReceiverHelper<!{{module.namespace}}.{{interface.name}}Remote>}
*/ */
this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_); this.$ = new mojo.internal.interfaceSupport.InterfaceReceiverHelper(this.helper_internal_);
......
...@@ -12,17 +12,8 @@ mojom("mojo_bindings") { ...@@ -12,17 +12,8 @@ mojom("mojo_bindings") {
] ]
} }
mojom("mojo_old_names_bindings") {
testonly = true
sources = [
"test_old_names.test-mojom",
]
use_old_js_lite_bindings_names = true
}
js_type_check("closure_compile") { js_type_check("closure_compile") {
deps = [ deps = [
":old_names_test",
":test", ":test",
] ]
} }
...@@ -30,12 +21,5 @@ js_type_check("closure_compile") { ...@@ -30,12 +21,5 @@ js_type_check("closure_compile") {
js_library("test") { js_library("test") {
deps = [ deps = [
":mojo_bindings_js_library_for_compile", ":mojo_bindings_js_library_for_compile",
":mojo_old_names_bindings_js_library_for_compile",
]
}
js_library("old_names_test") {
deps = [
":mojo_old_names_bindings_js_library_for_compile",
] ]
} }
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(() => {
async function testFunction() {
/** @type {oldNameTest.mojom.TestPageHandlerProxy} */
let proxy = oldNameTest.mojom.TestPageHandler.getProxy()
// Type infers {?{values: !Array<!string>}} from Promise return type.
let result = await proxy.method1(' ', 5);
/** @type {Array<string>} */
let values = result.values;
/** @type {oldNameTest.mojom.TestStruct} */
let testStruct = result.ts
}
/** @implements {oldNameTest.mojom.TestPageInterface} */
class TestPageImpl {
/** @override */
onEvent1(s) {
/** @type {oldNameTest.mojom.TestStruct} */ let t = s;
/** @type {string} */ let id = t.id;
/** @type {string|undefined} */ let title = t.title;
/** @type {oldNameTest.mojom.TestEnum} */ let enumValue = t.enums[0];
/** @type {string} */ let numberToStringMapValue = t.numberToStringMap[5];
/** @type {oldNameTest.mojom.Message} */
let messageToMessageArrayValue =
t.messageToArrayMap.get({message: 'asdf'})[0];
/** @type {oldNameTest.mojom.TestEnum} */ let enumToMapMapValue =
t.enumToMapMap[oldNameTest.mojom.TestEnum.FIRST]
[oldNameTest.mojom.TestEnum.SECOND];
/** @type {oldNameTest.mojom.TestPageInterface} */
let handler = t.numberToInterfaceProxyMap[3];
handler.onEvent1(t);
}
}
})();
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module old_name_test.mojom;
enum TestEnum {
FIRST,
SECOND,
};
struct Message {
string message;
};
struct TestStruct {
string id;
string? title;
array<TestEnum> enums;
map<uint32, string> numberToStringMap;
map<Message, array<Message>> messageToArrayMap;
map<TestEnum, map<TestEnum, TestEnum>> enumToMapMap;
map<uint32, TestPage> numberToInterfaceProxyMap;
};
interface TestPageHandler {
Method1(string p1, int32 p2) => (array<string> values, TestStruct ts);
};
interface TestPage {
OnEvent1(TestStruct s);
};
...@@ -264,8 +264,6 @@ class Generator(generator.Generator): ...@@ -264,8 +264,6 @@ class Generator(generator.Generator):
"unions": self.module.unions, "unions": self.module.unions,
"generate_fuzzing": self.generate_fuzzing, "generate_fuzzing": self.generate_fuzzing,
"generate_closure_exports": for_compile, "generate_closure_exports": for_compile,
"use_old_names": self.use_old_js_lite_bindings_names,
"primitives_names": self._GetPrimitivesNames(),
} }
@staticmethod @staticmethod
...@@ -474,9 +472,9 @@ class Generator(generator.Generator): ...@@ -474,9 +472,9 @@ class Generator(generator.Generator):
mojom.IsEnumKind(kind)): mojom.IsEnumKind(kind)):
return name return name
if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind): if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind):
return name + self._GetPrimitivesNames()["remote"] return name + "Remote"
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return name + self._GetPrimitivesNames()["pending_receiver"] return name + "PendingReceiver"
# TODO(calamity): Support associated interfaces properly. # TODO(calamity): Support associated interfaces properly.
if (mojom.IsAssociatedInterfaceKind(kind) or if (mojom.IsAssociatedInterfaceKind(kind) or
mojom.IsPendingAssociatedRemoteKind(kind)): mojom.IsPendingAssociatedRemoteKind(kind)):
...@@ -573,21 +571,17 @@ class Generator(generator.Generator): ...@@ -573,21 +571,17 @@ class Generator(generator.Generator):
mojom.IsEnumKind(kind)): mojom.IsEnumKind(kind)):
return "%sSpec.$" % name return "%sSpec.$" % name
if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind): if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind):
remote_name = name + self._GetPrimitivesNames()["remote"] return "mojo.internal.InterfaceProxy(%sRemote)" % name
return "mojo.internal.InterfaceProxy(%s)" % remote_name
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
request_name = name + self._GetPrimitivesNames()["pending_receiver"] return "mojo.internal.InterfaceRequest(%sPendingReceiver)" % name
return "mojo.internal.InterfaceRequest(%s)" % request_name
if (mojom.IsAssociatedInterfaceKind(kind) or if (mojom.IsAssociatedInterfaceKind(kind) or
mojom.IsPendingAssociatedRemoteKind(kind)): mojom.IsPendingAssociatedRemoteKind(kind)):
remote_name = name + self._GetPrimitivesNames()["remote"]
# TODO(rockot): Implement associated interfaces. # TODO(rockot): Implement associated interfaces.
return "mojo.internal.AssociatedInterfaceProxy(%s)" % ( return "mojo.internal.AssociatedInterfaceProxy(%sRemote)" % (name)
remote_name)
if (mojom.IsAssociatedInterfaceRequestKind(kind) or if (mojom.IsAssociatedInterfaceRequestKind(kind) or
mojom.IsPendingAssociatedReceiverKind(kind)): mojom.IsPendingAssociatedReceiverKind(kind)):
request_name = name + self._GetPrimitivesNames()["pending_receiver"] return "mojo.internal.AssociatedInterfaceRequest(%sPendingReceiver)" % (
return "mojo.internal.AssociatedInterfaceRequest(%s)" % request_name name)
return name return name
...@@ -826,20 +820,6 @@ class Generator(generator.Generator): ...@@ -826,20 +820,6 @@ class Generator(generator.Generator):
return self._ExpressionToText(token) return self._ExpressionToText(token)
def _GetPrimitivesNames(self):
if self.use_old_js_lite_bindings_names:
return {
"remote": "Proxy",
"receiver": "",
"pending_receiver": "Request",
}
else:
return {
"remote": "Remote",
"receiver": "Receiver",
"pending_receiver": "PendingReceiver",
}
def _GenerateHtmlImports(self): def _GenerateHtmlImports(self):
result = [] result = []
for full_import in self.module.imports: for full_import in self.module.imports:
......
...@@ -291,10 +291,6 @@ if (enable_mojom_typemapping) { ...@@ -291,10 +291,6 @@ if (enable_mojom_typemapping) {
# correct dependency order. Note that this only has an effect if # correct dependency order. Note that this only has an effect if
# the |enable_mojom_closure_compile| global arg is set to |true| as well. # the |enable_mojom_closure_compile| global arg is set to |true| as well.
# #
# use_old_js_lite_bindings_names (optional)
# Use old names i.e. FooProxy, Foo, getProxy(), etc. instead of the new
# names i.e. FooRemote, FooReceiver, getRemote(), etc.
#
# use_typescript_sources (optional) # use_typescript_sources (optional)
# Uses the Typescript generator to generate JavaScript bindings. # Uses the Typescript generator to generate JavaScript bindings.
# #
...@@ -1296,11 +1292,6 @@ template("mojom") { ...@@ -1296,11 +1292,6 @@ template("mojom") {
if (generate_fuzzing) { if (generate_fuzzing) {
args += [ "--generate_fuzzing" ] args += [ "--generate_fuzzing" ]
} }
if (defined(invoker.use_old_js_lite_bindings_names) &&
invoker.use_old_js_lite_bindings_names) {
args += [ "--use_old_js_lite_bindings_names" ]
}
} }
} }
......
...@@ -219,7 +219,6 @@ class MojomProcessor(object): ...@@ -219,7 +219,6 @@ class MojomProcessor(object):
variant=args.variant, bytecode_path=args.bytecode_path, variant=args.variant, bytecode_path=args.bytecode_path,
for_blink=args.for_blink, for_blink=args.for_blink,
js_bindings_mode=args.js_bindings_mode, js_bindings_mode=args.js_bindings_mode,
use_old_js_lite_bindings_names=args.use_old_js_lite_bindings_names,
export_attribute=args.export_attribute, export_attribute=args.export_attribute,
export_header=args.export_header, export_header=args.export_header,
generate_non_variant_code=args.generate_non_variant_code, generate_non_variant_code=args.generate_non_variant_code,
...@@ -471,11 +470,6 @@ def main(): ...@@ -471,11 +470,6 @@ def main():
help="This option only affects the JavaScript bindings. The value could " help="This option only affects the JavaScript bindings. The value could "
"be \"new\" to generate new-style lite JS bindings in addition to the " "be \"new\" to generate new-style lite JS bindings in addition to the "
"old, or \"old\" to only generate old bindings.") "old, or \"old\" to only generate old bindings.")
generate_parser.add_argument(
"--use_old_js_lite_bindings_names", action="store_true",
help="This option only affects the JavaScript bindings. Specifying this "
"argument causes the generated new-style lite JS bindings to use the old"
"names for primitives e.g. Foo, FooProxy, getProxy(), etc.")
generate_parser.add_argument( generate_parser.add_argument(
"--export_attribute", default="", "--export_attribute", default="",
help="Optional attribute to specify on class declaration to export it " help="Optional attribute to specify on class declaration to export it "
......
...@@ -194,7 +194,6 @@ class Generator(object): ...@@ -194,7 +194,6 @@ class Generator(object):
def __init__(self, module, output_dir=None, typemap=None, variant=None, def __init__(self, module, output_dir=None, typemap=None, variant=None,
bytecode_path=None, for_blink=False, bytecode_path=None, for_blink=False,
js_bindings_mode="new", js_bindings_mode="new",
use_old_js_lite_bindings_names=False,
export_attribute=None, export_attribute=None,
export_header=None, generate_non_variant_code=False, export_header=None, generate_non_variant_code=False,
support_lazy_serialization=False, disallow_native_types=False, support_lazy_serialization=False, disallow_native_types=False,
...@@ -207,7 +206,6 @@ class Generator(object): ...@@ -207,7 +206,6 @@ class Generator(object):
self.bytecode_path = bytecode_path self.bytecode_path = bytecode_path
self.for_blink = for_blink self.for_blink = for_blink
self.js_bindings_mode = js_bindings_mode self.js_bindings_mode = js_bindings_mode
self.use_old_js_lite_bindings_names = use_old_js_lite_bindings_names
self.export_attribute = export_attribute self.export_attribute = export_attribute
self.export_header = export_header self.export_header = export_header
self.generate_non_variant_code = generate_non_variant_code self.generate_non_variant_code = generate_non_variant_code
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="/gen/content/test/data/lite_js_old_names_test.mojom-lite.js"></script>
<script>
'use strict';
const kTestMessage = 'hello there';
const kTestNumbers = [0, 1, 1, 2, 3, 5, 8, 13, 21];
class TargetImpl {
constructor() {
this.numPokes = 0;
this.target = new liteJsOldNamesTest.mojom.TestMessageTarget(this);
}
poke() { this.numPokes++; }
ping() { return Promise.resolve(); }
repeat(message, numbers) { return {message: message, numbers: numbers}; }
flatten(values) {}
flattenUnions(unions) {}
requestSubinterface(request, client) {}
}
promise_test(() => {
let impl = new TargetImpl;
let proxy = impl.target.$.createProxy();
proxy.poke();
return proxy.ping().then(() => {
assert_equals(impl.numPokes, 1);
});
}, 'messages with replies return Promises that resolve on reply received');
promise_test(() => {
let impl = new TargetImpl;
let proxy = impl.target.$.createProxy();
return proxy.repeat(kTestMessage, kTestNumbers)
.then(reply => {
assert_equals(reply.message, kTestMessage);
assert_array_equals(reply.numbers, kTestNumbers);
});
}, 'implementations can reply with multiple reply arguments');
promise_test(async (t) => {
const impl = new TargetImpl;
const proxy = impl.target.$.createProxy();
await proxy.ping();
proxy.$.close();
await promise_rejects(t, new Error(), proxy.ping());
}, 'after the pipe is closed all future calls should fail');
promise_test(async (t) => {
const impl = new TargetImpl;
const proxy = impl.target.$.createProxy();
// None of these promises should successfully resolve because we are
// immediately closing the pipe.
const promises = []
for (let i = 0; i < 10; i++) {
promises.push(proxy.ping());
}
proxy.$.close();
for (const promise of promises) {
await promise_rejects(t, new Error(), promise);
}
}, 'closing the pipe drops any pending messages');
promise_test(() => {
let impl = new TargetImpl;
// Intercept any browser-bound request for TestMessageTarget and bind it
// instead to the local |impl| object.
let interceptor = new MojoInterfaceInterceptor(
liteJsOldNamesTest.mojom.TestMessageTarget.$interfaceName);
interceptor.oninterfacerequest = e => {
impl.target.$.bindHandle(e.handle);
}
interceptor.start();
let proxy = liteJsOldNamesTest.mojom.TestMessageTarget.getProxy();
proxy.poke();
return proxy.ping().then(() => {
assert_equals(impl.numPokes, 1);
});
}, 'getProxy() attempts to send requests to the frame host');
promise_test(() => {
let router = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
let proxy = router.$.createProxy();
return new Promise(resolve => {
router.poke.addListener(resolve);
proxy.poke();
});
}, 'basic generated CallbackRouter behavior works as intended');
promise_test(() => {
let router = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
let proxy = router.$.createProxy();
let numPokes = 0;
router.poke.addListener(() => ++numPokes);
router.ping.addListener(() => Promise.resolve());
proxy.poke();
return proxy.ping().then(() => assert_equals(numPokes, 1));
}, 'CallbackRouter listeners can reply to messages');
promise_test(() => {
let router = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
let proxy = router.$.createProxy();
router.repeat.addListener(
(message, numbers) => ({message: message, numbers: numbers}));
return proxy.repeat(kTestMessage, kTestNumbers)
.then(reply => {
assert_equals(reply.message, kTestMessage);
assert_array_equals(reply.numbers, kTestNumbers);
});
}, 'CallbackRouter listeners can reply with multiple reply arguments');
promise_test(() => {
let targetRouter = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
let targetProxy = targetRouter.$.createProxy();
let subinterfaceRouter = new liteJsOldNamesTest.mojom.SubinterfaceCallbackRouter;
targetRouter.requestSubinterface.addListener((request, client) => {
let values = [];
subinterfaceRouter.$.bindHandle(request.handle);
subinterfaceRouter.push.addListener(value => values.push(value));
subinterfaceRouter.flush.addListener(() => {
client.didFlush(values);
values = [];
});
});
let clientRouter = new liteJsOldNamesTest.mojom.SubinterfaceClientCallbackRouter;
let subinterfaceProxy = new liteJsOldNamesTest.mojom.SubinterfaceProxy;
targetProxy.requestSubinterface(
subinterfaceProxy.$.createRequest(), clientRouter.$.createProxy());
return new Promise(resolve => {
clientRouter.didFlush.addListener(values => {
assert_array_equals(values, kTestNumbers);
resolve();
});
kTestNumbers.forEach(n => subinterfaceProxy.push(n));
subinterfaceProxy.flush();
});
}, 'can send and receive interface requests and proxies');
promise_test(() => {
const targetRouter = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
const targetProxy = targetRouter.$.createProxy();
targetRouter.flatten.addListener(values => ({values: values.map(v => v.x)}));
return targetProxy.flatten([{x: 1}, {x: 2}, {x: 3}]).then(reply => {
assert_array_equals(reply.values, [1, 2, 3]);
});
}, 'regression test for complex array serialization');
promise_test(() => {
const targetRouter = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
const targetProxy = targetRouter.$.createProxy();
targetRouter.flattenUnions.addListener(unions => {
return {x: unions.filter(u => u.x !== undefined).map(u => u.x),
s: unions.filter(u => u.s !== undefined).map(u => u.s.x)};
});
return targetProxy.flattenUnions(
[{x: 1}, {x: 2}, {s: {x: 3}}, {s: {x: 4}}, {x: 5}, {s: {x: 6}}])
.then(reply => {
assert_array_equals(reply.x, [1, 2, 5]);
assert_array_equals(reply.s, [3, 4, 6]);
});
}, 'can serialize and deserialize unions');
promise_test(() => {
let impl = new TargetImpl;
let proxy = impl.target.$.createProxy();
// Poke a bunch of times. These should never race with the assertion below,
// because the |flushForTesting| request/response is ordered against other
// messages on |proxy|.
const kNumPokes = 100;
for (let i = 0; i < kNumPokes; ++i)
proxy.poke();
return proxy.$.flushForTesting().then(() => {
assert_equals(impl.numPokes, kNumPokes);
});
}, 'can use generated flushForTesting API for synchronization in tests');
promise_test(async(t) => {
const impl = new TargetImpl;
const proxy = impl.target.$.createProxy();
const disconnectPromise = new Promise(resolve => impl.target.onConnectionError.addListener(resolve));
proxy.$.close();
return disconnectPromise;
}, 'InterfaceTarget connection error handler runs when set on an Interface object');
promise_test(() => {
const router = new liteJsOldNamesTest.mojom.TestMessageTargetCallbackRouter;
const proxy = router.$.createProxy();
const disconnectPromise = new Promise(resolve => router.onConnectionError.addListener(resolve));
proxy.$.close();
return disconnectPromise;
}, 'InterfaceTarget connection error handler runs when set on an InterfaceCallbackRouter object');
</script>
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