Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: ios/web/test/data/mojo_test.js

Issue 2946383002: Support new-style Mojo JS core API on IOS. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/webui/crw_web_ui_manager.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/test/data/mojo_test.js
diff --git a/ios/web/test/data/mojo_test.js b/ios/web/test/data/mojo_test.js
index 6c48ccada6ab745828b428e246f27ede7d4f8e25..d20a38eb76f27d865c1e5bfac9d5bcfd72b55012 100644
--- a/ios/web/test/data/mojo_test.js
+++ b/ios/web/test/data/mojo_test.js
@@ -8,42 +8,24 @@
// "fin" is received by the native page. Refer to
// ios/web/webui/web_ui_mojo_inttest.mm for testing code.
-/** @return {!Promise} */
-function getBrowserProxy() {
- return new Promise(function(resolve, reject) {
- define([
- 'mojo/public/js/bindings',
- 'ios/web/test/mojo_test.mojom',
- 'content/public/renderer/frame_interfaces',
- ], function(bindings, mojom, frameInterfaces) {
- var pageImpl, browserProxy;
-
- /** @constructor */
- function TestPageImpl() {
- this.binding = new bindings.Binding(mojom.TestPage, this);
- }
-
- TestPageImpl.prototype = {
- /** @override */
- handleNativeMessage: function(result) {
- if (result.message == 'ack') {
- // Native code has replied with "ack", send "fin" to complete the
- // test.
- browserProxy.handleJsMessage('fin');
- }
- },
- };
+var pageImpl, browserProxy;
- browserProxy = new mojom.TestUIHandlerMojoPtr(
- frameInterfaces.getInterface(mojom.TestUIHandlerMojo.name));
- pageImpl = new TestPageImpl();
-
- browserProxy.setClientPage(pageImpl.binding.createInterfacePtrAndBind());
- resolve(browserProxy);
- });
- });
+/** @constructor */
+function TestPageImpl() {
+ this.binding = new mojo.Binding(TestPage, this);
}
+TestPageImpl.prototype = {
+ /** @override */
+ handleNativeMessage: function(result) {
+ if (result.message == 'ack') {
+ // Native code has replied with "ack", send "fin" to complete the
+ // test.
+ browserProxy.handleJsMessage('fin');
+ }
+ },
+};
+
/**
* @return {!Promise} Fires when DOMContentLoaded event is received.
*/
@@ -54,11 +36,19 @@ function whenDomContentLoaded() {
}
function main() {
- Promise.all([
- getBrowserProxy(), whenDomContentLoaded()
- ]).then(function([browserProxy]) {
+ whenDomContentLoaded().then(function() {
+ browserProxy = new TestUIHandlerMojoPtr();
+ Mojo.bindInterface(TestUIHandlerMojo.name,
+ mojo.makeRequest(browserProxy).handle);
+
+ pageImpl = new TestPageImpl();
+ var pagePtr = new TestPagePtr();
+ pageImpl.binding.bind(mojo.makeRequest(pagePtr));
+ browserProxy.setClientPage(pagePtr);
+
// Send "syn" so native code should reply with "ack".
browserProxy.handleJsMessage('syn');
});
}
+
main();
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/webui/crw_web_ui_manager.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698