| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Whitebox integration/end-to-end test of Try Dart! site. | 5 /// Whitebox integration/end-to-end test of Try Dart! site. |
| 6 /// | 6 /// |
| 7 /// This test opens Try Dart! in an iframe. When opened the first time, Try | 7 /// This test opens Try Dart! in an iframe. When opened the first time, Try |
| 8 /// Dart! will display a simple hello-world example, color tokens, compile the | 8 /// Dart! will display a simple hello-world example, color tokens, compile the |
| 9 /// example, and run the result. We've instrumented Try Dart! to use | 9 /// example, and run the result. We've instrumented Try Dart! to use |
| 10 /// window.parent.postMessage when the running program prints anything. So this | 10 /// window.parent.postMessage when the running program prints anything. So this |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 String message = eventProxy['message']; | 34 String message = eventProxy['message']; |
| 35 print("Error occurred in iframe: $message"); | 35 print("Error occurred in iframe: $message"); |
| 36 new Future(() { | 36 new Future(() { |
| 37 // Chrome seems to not call window.onerror when you throw in response to | 37 // Chrome seems to not call window.onerror when you throw in response to |
| 38 // an error event. So we throw the error in a future. | 38 // an error event. So we throw the error in a future. |
| 39 throw 'Error from iframe: $filename:$lineno: $message'; | 39 throw 'Error from iframe: $filename:$lineno: $message'; |
| 40 }); | 40 }); |
| 41 }]); | 41 }]); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void onIframeLoaded(ErrorEvent event) { | 44 void onIframeLoaded(Event event) { |
| 45 installErrorHandlerOn(event.target); | 45 installErrorHandlerOn(event.target); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void main() { | 48 void main() { |
| 49 asyncStart(); | 49 asyncStart(); |
| 50 window.onMessage.listen((MessageEvent e) { | 50 window.onMessage.listen((MessageEvent e) { |
| 51 if (e.data == 'Hello, World!\n') { | 51 if (e.data == 'Hello, World!\n') { |
| 52 // Clear the DOM to work around a bug in test.dart. | 52 // Clear the DOM to work around a bug in test.dart. |
| 53 document.body.nodes.clear(); | 53 document.body.nodes.clear(); |
| 54 | 54 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 ..src = '/root_build/try_dartlang_org/index.html' | 69 ..src = '/root_build/try_dartlang_org/index.html' |
| 70 ..style.width = '90vw' | 70 ..style.width = '90vw' |
| 71 ..style.height = '90vh' | 71 ..style.height = '90vh' |
| 72 ..onLoad.listen(onIframeLoaded); | 72 ..onLoad.listen(onIframeLoaded); |
| 73 document.body.append(iframe); | 73 document.body.append(iframe); |
| 74 // Install an error handler both on the new iframe element, and when it has | 74 // Install an error handler both on the new iframe element, and when it has |
| 75 // fired the load event. That seems to matter according to some sources on | 75 // fired the load event. That seems to matter according to some sources on |
| 76 // stackoverflow. | 76 // stackoverflow. |
| 77 installErrorHandlerOn(iframe); | 77 installErrorHandlerOn(iframe); |
| 78 } | 78 } |
| OLD | NEW |