blob: 61734d484e5dda88d6423d210b0b0f9a25418442 [file] [log] [blame]
<!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">
<meta charset="UTF-8">
<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.
// 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 ([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 =[1];
script.type = 'application/javascript';
} else if ([0] === 'apply-update') {
// Let the sandbox embedder know that main is done running.
window.parent.postMessage('iframe-dart-updated-main-done', '*');
} else {
// Other messages are just logged.
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', '*');