| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <!-- Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 3 -- for details. All rights reserved. Use of this source code is governed by a | |
| 4 -- BSD-style license that can be found in the LICENSE file. | |
| 5 --> | |
| 6 <html lang="en"> | |
| 7 <head> | |
| 8 <title>incremental_compilation_update_test.html</title> | |
| 9 <meta charset="UTF-8"> | |
| 10 </head> | |
| 11 <body> | |
| 12 <h1>incremental_compilation_update_test.html</h1> | |
| 13 <pre id="console"></pre> | |
| 14 <script type="application/javascript" src="print.js"></script> | |
| 15 <script type="application/javascript"> | |
| 16 (function() { | |
| 17 var dartMainClosure; | |
| 18 | |
| 19 /// Invoked by JavaScript code generated by dart2js when the program is ready | |
| 20 /// to invoke main. | |
| 21 self.dartMainRunner = function dartMainRunner(main) { | |
| 22 dartMainClosure = main; | |
| 23 | |
| 24 // Invoke the "main" method of the Dart program. | |
| 25 main(); | |
| 26 | |
| 27 // Let the sandbox embedder know that main is done running. | |
| 28 window.parent.postMessage('iframe-dart-main-done', '*'); | |
| 29 } | |
| 30 | |
| 31 /// Invoked when a 'message' event is received. Message events are generated | |
| 32 /// with Window.postMessage and used to communicate between this iframe and | |
| 33 /// its embedding parent page. | |
| 34 function onMessage(e) { | |
| 35 if (e.data[0] === 'add-script') { | |
| 36 // Received a message on the form ['add-script', uri]. | |
| 37 // Install a new script tag with the uri. | |
| 38 var script = document.createElement('script'); | |
| 39 script.src = e.data[1]; | |
| 40 script.type = 'application/javascript'; | |
| 41 document.body.appendChild(script); | |
| 42 } else if (e.data[0] === 'apply-update') { | |
| 43 self.$dart_unsafe_incremental_support.patch(e.data[1]); | |
| 44 | |
| 45 dartMainClosure(); | |
| 46 | |
| 47 // Let the sandbox embedder know that main is done running. | |
| 48 window.parent.postMessage('iframe-dart-updated-main-done', '*'); | |
| 49 } else { | |
| 50 // Other messages are just logged. | |
| 51 console.log(e); | |
| 52 } | |
| 53 } | |
| 54 window.addEventListener('message', onMessage, false); | |
| 55 | |
| 56 // Let the sandbox embedder know that this iframe is ready, that is, | |
| 57 // listening for messages. | |
| 58 window.parent.postMessage('iframe-ready', '*'); | |
| 59 | |
| 60 })(); | |
| 61 </script> | |
| 62 </body> | |
| 63 </html> | |
| OLD | NEW |