| <!DOCTYPE html> |
| <!-- Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| -- for details. All rights reserved. Use of this source code is governed by a |
| -- BSD-style license that can be found in the LICENSE file. |
| --> |
| <html lang="en"> |
| <head> |
| <title>incremental_compilation_update_test.html</title> |
| <meta charset="UTF-8"> |
| </head> |
| <body> |
| <h1>incremental_compilation_update_test.html</h1> |
| <pre id="console"></pre> |
| <script type="application/javascript" src="print.js"></script> |
| <script type="application/javascript"> |
| (function() { |
| var dartMainClosure; |
| |
| /// Invoked by JavaScript code generated by dart2js when the program is ready |
| /// to invoke main. |
| self.dartMainRunner = function dartMainRunner(main) { |
| dartMainClosure = main; |
| |
| // Invoke the "main" method of the Dart program. |
| main(); |
| |
| // Let the sandbox embedder know that main is done running. |
| window.parent.postMessage('iframe-dart-main-done', '*'); |
| } |
| |
| /// Invoked when a 'message' event is received. Message events are generated |
| /// with Window.postMessage and used to communicate between this iframe and |
| /// its embedding parent page. |
| function onMessage(e) { |
| if (e.data[0] === 'add-script') { |
| // Received a message on the form ['add-script', uri]. |
| // Install a new script tag with the uri. |
| var script = document.createElement('script'); |
| script.src = e.data[1]; |
| script.type = 'application/javascript'; |
| document.body.appendChild(script); |
| } else if (e.data[0] === 'apply-update') { |
| self.$dart_unsafe_incremental_support.patch(e.data[1]); |
| |
| dartMainClosure(); |
| |
| // Let the sandbox embedder know that main is done running. |
| window.parent.postMessage('iframe-dart-updated-main-done', '*'); |
| } else { |
| // Other messages are just logged. |
| console.log(e); |
| } |
| } |
| window.addEventListener('message', onMessage, false); |
| |
| // Let the sandbox embedder know that this iframe is ready, that is, |
| // listening for messages. |
| window.parent.postMessage('iframe-ready', '*'); |
| |
| })(); |
| </script> |
| </body> |
| </html> |