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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // to provide more details on both Chrome and Firefox (which provides no | 62 // to provide more details on both Chrome and Firefox (which provides no |
63 // information at all in error events). | 63 // information at all in error events). |
64 contentWindowProxy['onerror'] = onError; | 64 contentWindowProxy['onerror'] = onError; |
65 } | 65 } |
66 | 66 |
67 void onIframeLoaded(Event event) { | 67 void onIframeLoaded(Event event) { |
68 installErrorHandlerOn(event.target); | 68 installErrorHandlerOn(event.target); |
69 } | 69 } |
70 | 70 |
71 void main() { | 71 void main() { |
| 72 document.cookie = 'org-trydart-AutomatedTest=true;path=/'; |
72 asyncStart(); | 73 asyncStart(); |
73 window.onMessage.listen((MessageEvent e) { | 74 window.onMessage.listen((MessageEvent e) { |
74 switch (e.data) { | 75 switch (e.data) { |
75 case 'Hello, World!\n': | 76 case 'Hello, World!\n': |
76 // Clear the DOM to work around a bug in test.dart. | 77 // Clear the DOM to work around a bug in test.dart. |
77 document.body.nodes.clear(); | 78 document.body.nodes.clear(); |
78 | 79 |
79 // Clean up after ourselves. | 80 // Clean up after ourselves. |
80 window.localStorage.clear(); | 81 window.localStorage.clear(); |
81 | 82 |
(...skipping 21 matching lines...) Expand all Loading... |
103 ..src = '/root_build/try_dartlang_org/index.html' | 104 ..src = '/root_build/try_dartlang_org/index.html' |
104 ..style.width = '90vw' | 105 ..style.width = '90vw' |
105 ..style.height = '90vh' | 106 ..style.height = '90vh' |
106 ..onLoad.listen(onIframeLoaded); | 107 ..onLoad.listen(onIframeLoaded); |
107 document.body.append(iframe); | 108 document.body.append(iframe); |
108 // Install an error handler both on the new iframe element, and when it has | 109 // Install an error handler both on the new iframe element, and when it has |
109 // fired the load event. That seems to matter according to some sources on | 110 // fired the load event. That seems to matter according to some sources on |
110 // stackoverflow. | 111 // stackoverflow. |
111 installErrorHandlerOn(iframe); | 112 installErrorHandlerOn(iframe); |
112 } | 113 } |
OLD | NEW |