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") { ...@@ -13,9 +13,6 @@ mojom("media_controller") {
public_deps = [ public_deps = [
"//mojo/common:common_custom_types", "//mojo/common:common_custom_types",
] ]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
} }
mojom("media_router") { mojom("media_router") {
...@@ -31,9 +28,6 @@ mojom("media_router") { ...@@ -31,9 +28,6 @@ mojom("media_router") {
"//url/mojo:url_mojom_gurl", "//url/mojo:url_mojom_gurl",
"//url/mojo:url_mojom_origin", "//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") { mojom("media_router_test_interfaces") {
......
...@@ -36,9 +36,6 @@ if (enable_extensions) { ...@@ -36,9 +36,6 @@ if (enable_extensions) {
"//mojo/common:common_custom_types", "//mojo/common:common_custom_types",
"//url/mojo:url_mojom_gurl", "//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 # This must be a static library because extensions common depends on
......
...@@ -36,10 +36,8 @@ class MojoPrivateApiTest : public ApiTestBase { ...@@ -36,10 +36,8 @@ class MojoPrivateApiTest : public ApiTestBase {
}; };
TEST_F(MojoPrivateApiTest, RequireAsync) { TEST_F(MojoPrivateApiTest, RequireAsync) {
env()->RegisterModule("add", env()->RegisterModule(
"define('add', [], function() {" "add", "exports.$set('returnValue', function(x, y) { return x + y; });");
" return { Add: function(x, y) { return x + y; } };"
"});");
ASSERT_NO_FATAL_FAILURE( ASSERT_NO_FATAL_FAILURE(
RunTest("mojo_private_unittest.js", "testRequireAsync")); RunTest("mojo_private_unittest.js", "testRequireAsync"));
} }
......
...@@ -14,7 +14,9 @@ var NO_STREAM_ERROR = ...@@ -14,7 +14,9 @@ var NO_STREAM_ERROR =
'Streams are only available from a mime handler view guest.'; 'Streams are only available from a mime handler view guest.';
var STREAM_ABORTED_ERROR = 'Stream has been aborted.'; 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'); loadScript('extensions/common/api/mime_handler.mojom');
var servicePtr = new extensions.mimeHandler.MimeHandlerServicePtr; var servicePtr = new extensions.mimeHandler.MimeHandlerServicePtr;
......
...@@ -12,7 +12,7 @@ binding.registerCustomHook(function(bindingsAPI) { ...@@ -12,7 +12,7 @@ binding.registerCustomHook(function(bindingsAPI) {
let apiFunctions = bindingsAPI.apiFunctions; let apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setHandleRequest('requireAsync', function(moduleName) { apiFunctions.setHandleRequest('requireAsync', function(moduleName) {
return requireAsync(moduleName); return Promise.resolve(require(moduleName).returnValue);
}); });
}); });
......
...@@ -13,7 +13,7 @@ unittestBindings.exportTests([ ...@@ -13,7 +13,7 @@ unittestBindings.exportTests([
function testRequireAsync() { function testRequireAsync() {
mojoPrivate.requireAsync('add').then( mojoPrivate.requireAsync('add').then(
test.callbackPass(function(add) { test.callbackPass(function(add) {
test.assertEq('function', typeof add.Add); test.assertEq('function', typeof add);
})); }));
}, },
], test.runTests, exports); ], test.runTests, exports);
...@@ -69,9 +69,6 @@ mojom("remoting_common") { ...@@ -69,9 +69,6 @@ mojom("remoting_common") {
sources = [ sources = [
"remoting_common.mojom", "remoting_common.mojom",
] ]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
} }
mojom("mirror_service_remoting") { mojom("mirror_service_remoting") {
...@@ -82,9 +79,6 @@ mojom("mirror_service_remoting") { ...@@ -82,9 +79,6 @@ mojom("mirror_service_remoting") {
public_deps = [ public_deps = [
":remoting_common", ":remoting_common",
] ]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
use_new_js_bindings = false
} }
mojom("remoting") { mojom("remoting") {
......
...@@ -31,9 +31,6 @@ mojom("common_custom_types") { ...@@ -31,9 +31,6 @@ mojom("common_custom_types") {
if (is_win) { if (is_win) {
sources += [ "logfont_win.mojom" ] sources += [ "logfont_win.mojom" ]
} }
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
} }
mojom("read_only_buffer") { mojom("read_only_buffer") {
......
...@@ -13,7 +13,4 @@ mojom("interfaces") { ...@@ -13,7 +13,4 @@ mojom("interfaces") {
public_deps = [ public_deps = [
"//url/mojo:url_mojom_gurl", "//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") { ...@@ -8,9 +8,6 @@ mojom("url_mojom_gurl") {
sources = [ sources = [
"url.mojom", "url.mojom",
] ]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
} }
mojom("url_mojom_origin") { mojom("url_mojom_origin") {
...@@ -21,9 +18,6 @@ mojom("url_mojom_origin") { ...@@ -21,9 +18,6 @@ mojom("url_mojom_origin") {
public_deps = [ public_deps = [
":url_mojom_gurl", ":url_mojom_gurl",
] ]
# TODO(crbug.com/699569): Convert to use the new JS bindings.
js_bindings_mode = "both"
} }
mojom("test_url_mojom_gurl") { 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