Commit cd47059e authored by Yuzhu Shen's avatar Yuzhu Shen Committed by Commit Bot

Extensions: convert media_router_bindings.js to use new Mojo JS bindings.

This CL also changes the mojoPrivate API to be simply an async wrapper around
require().

Bug: 699569, 718047
Change-Id: I271887d1cc1eb49fd2faefff47467c47be23a3be
Reviewed-on: https://chromium-review.googlesource.com/783645Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Yuzhu Shen <yzshen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521129}
parent eece1344
......@@ -13,9 +13,6 @@ mojom("media_controller") {
public_deps = [
"//mojo/common:common_custom_types",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
}
mojom("media_router") {
......@@ -31,9 +28,6 @@ mojom("media_router") {
"//url/mojo:url_mojom_gurl",
"//url/mojo:url_mojom_origin",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
}
mojom("media_router_test_interfaces") {
......
......@@ -36,9 +36,6 @@ if (enable_extensions) {
"//mojo/common:common_custom_types",
"//url/mojo:url_mojom_gurl",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
}
# This must be a static library because extensions common depends on
......
......@@ -36,10 +36,8 @@ class MojoPrivateApiTest : public ApiTestBase {
};
TEST_F(MojoPrivateApiTest, RequireAsync) {
env()->RegisterModule("add",
"define('add', [], function() {"
" return { Add: function(x, y) { return x + y; } };"
"});");
env()->RegisterModule(
"add", "exports.$set('returnValue', function(x, y) { return x + y; });");
ASSERT_NO_FATAL_FAILURE(
RunTest("mojo_private_unittest.js", "testRequireAsync"));
}
......
......@@ -14,7 +14,9 @@ var NO_STREAM_ERROR =
'Streams are only available from a mime handler view guest.';
var STREAM_ABORTED_ERROR = 'Stream has been aborted.';
loadScript('mojo_bindings');
if ((typeof mojo === 'undefined') || !mojo.bindingsLibraryInitialized) {
loadScript('mojo_bindings');
}
loadScript('extensions/common/api/mime_handler.mojom');
var servicePtr = new extensions.mimeHandler.MimeHandlerServicePtr;
......
......@@ -12,7 +12,7 @@ binding.registerCustomHook(function(bindingsAPI) {
let apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setHandleRequest('requireAsync', function(moduleName) {
return requireAsync(moduleName);
return Promise.resolve(require(moduleName).returnValue);
});
});
......
......@@ -13,7 +13,7 @@ unittestBindings.exportTests([
function testRequireAsync() {
mojoPrivate.requireAsync('add').then(
test.callbackPass(function(add) {
test.assertEq('function', typeof add.Add);
test.assertEq('function', typeof add);
}));
},
], test.runTests, exports);
......@@ -69,9 +69,6 @@ mojom("remoting_common") {
sources = [
"remoting_common.mojom",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
}
mojom("mirror_service_remoting") {
......@@ -82,9 +79,6 @@ mojom("mirror_service_remoting") {
public_deps = [
":remoting_common",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
}
mojom("remoting") {
......
......@@ -31,9 +31,6 @@ mojom("common_custom_types") {
if (is_win) {
sources += [ "logfont_win.mojom" ]
}
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
}
mojom("read_only_buffer") {
......
......@@ -13,7 +13,4 @@ mojom("interfaces") {
public_deps = [
"//url/mojo:url_mojom_gurl",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
}
......@@ -8,9 +8,6 @@ mojom("url_mojom_gurl") {
sources = [
"url.mojom",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
}
mojom("url_mojom_origin") {
......@@ -21,9 +18,6 @@ mojom("url_mojom_origin") {
public_deps = [
":url_mojom_gurl",
]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
}
mojom("test_url_mojom_gurl") {
......
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