| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <body> | 2 <body> |
| 3 | 3 |
| 4 <div id='status'></div> | 4 <div id='status'></div> |
| 5 <iframe src='resources/pong.html'></iframe> | 5 <iframe src='resources/pong.html'></iframe> |
| 6 | 6 |
| 7 <script type='application/dart'> | 7 <script type='application/dart'> |
| 8 #import('dart:dom'); | 8 #import('dart:dom'); |
| 9 | 9 |
| 10 class MessageQueue { | 10 class MessageQueue { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 test(Event e) { | 55 test(Event e) { |
| 56 Window other = document.getElementsByTagName('iframe')[0].contentWindow; | 56 Window other = document.getElementsByTagName('iframe')[0].contentWindow; |
| 57 | 57 |
| 58 // FIXME: consider support for WebCore objects like File, FileList. | 58 // FIXME: consider support for WebCore objects like File, FileList. |
| 59 MessageQueue messageQueue = new MessageQueue(window, other, [null, 'I am a str
ing']); | 59 MessageQueue messageQueue = new MessageQueue(window, other, [null, 'I am a str
ing']); |
| 60 | 60 |
| 61 window.addEventListener( | 61 window.addEventListener( |
| 62 'message', | 62 'message', |
| 63 (Event event) { | 63 (Event event) { |
| 64 output('response received: ${event.data}'); | 64 output('response received: ${event.data}'); |
| 65 output('event.source === other: ' + (event.source === other)); | 65 output('event.source === other: ${event.source === other}'); |
| 66 messageQueue.scheduleNext(); | 66 messageQueue.scheduleNext(); |
| 67 }, | 67 }, |
| 68 false); | 68 false); |
| 69 | 69 |
| 70 try { | 70 try { |
| 71 other.postMessage(); | 71 other.postMessage(); |
| 72 } catch (var e) { | 72 } catch (var e) { |
| 73 output('.postMessage() throws: ${e}'); | 73 output('.postMessage() throws: ${e}'); |
| 74 } | 74 } |
| 75 | 75 |
| 76 try { | 76 try { |
| 77 other.postMessage(null); | 77 other.postMessage(null); |
| 78 } catch (var e) { | 78 } catch (var e) { |
| 79 output('.postMessage(null) throws: ${e}'); | 79 output('.postMessage(null) throws: ${e}'); |
| 80 } | 80 } |
| 81 | 81 |
| 82 messageQueue.run(); | 82 messageQueue.run(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 output(var object) { | 85 output(var object) { |
| 86 final status = document.getElementById('status'); | 86 final status = document.getElementById('status'); |
| 87 status.innerHTML += '$object<br>'; | 87 status.innerHTML = '${status.innerHTML}$object<br>'; |
| 88 } | 88 } |
| 89 | 89 |
| 90 </script> | 90 </script> |
| 91 | 91 |
| 92 <script> | 92 <script> |
| 93 if (window.navigator.webkitStartDart) | 93 if (window.navigator.webkitStartDart) |
| 94 navigator.webkitStartDart(); | 94 navigator.webkitStartDart(); |
| 95 </script> | 95 </script> |
| 96 | 96 |
| 97 </body> | 97 </body> |
| 98 </html> | 98 </html> |
| OLD | NEW |