OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This trivial app just loads "cnn.com" using the Mojo Network and URLLoader | 5 // This trivial app just loads "cnn.com" using the Mojo Network and URLLoader |
6 // services and then prints a brief summary of the response. | 6 // services and then prints a brief summary of the response. |
7 // | 7 // |
8 // To run it using js_standalone (don't forget the quotes): | 8 // To run it using mojo_js_standalone (don't forget the quotes): |
9 // mojo_shell 'mojo://js_standalone THIS_DIR/main.js' | 9 // mojo_shell 'mojo://js_standalone THIS_DIR/main.js' |
10 // | 10 // |
11 // To run it using js_content_handler this file must be specified as a URL. For | 11 // To run it using mojo_js_content handler this file must be specified as |
12 // example: | 12 // a URL. For example: |
13 // (cd YOUR_DIR/mojo/apps/js; python -m SimpleHTTPServer ) & | 13 // (cd YOUR_DIR/mojo/apps/js; python -m SimpleHTTPServer ) & |
14 // mojo_shell \ | 14 // mojo_shell \ |
15 // --content-handlers=application/javascript,mojo://js_content_handler \ | 15 // --content-handlers=application/javascript,mojo://js_content_handler \ |
16 // http://localhost:8000/test.js | 16 // http://localhost:8000/test.js |
17 | 17 |
18 define("test", [ | 18 define("test", [ |
19 "mojo/apps/js/mojo", | 19 "mojo/apps/js/mojo", |
20 "mojo/public/js/bindings/core", | 20 "mojo/public/js/bindings/core", |
21 "mojo/public/js/bindings/connection", | 21 "mojo/public/js/bindings/connection", |
22 "mojo/public/js/bindings/support", | 22 "mojo/public/js/bindings/support", |
(...skipping 23 matching lines...) Expand all Loading... |
46 for(var key in result.response) | 46 for(var key in result.response) |
47 console.log(key + " => " + result.response[key]); | 47 console.log(key + " => " + result.response[key]); |
48 var drainDataPromise = core.drainData(result.response.body); | 48 var drainDataPromise = core.drainData(result.response.body); |
49 drainDataPromise.then(function(result) { | 49 drainDataPromise.then(function(result) { |
50 console.log("read " + result.buffer.byteLength + " bytes"); | 50 console.log("read " + result.buffer.byteLength + " bytes"); |
51 }).then(function() { | 51 }).then(function() { |
52 mojo.quit(); | 52 mojo.quit(); |
53 }); | 53 }); |
54 }); | 54 }); |
55 }); | 55 }); |
OLD | NEW |