| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /* | 5 /* |
| 6 * The communication protocol between test_controller.js and the driving | 6 * The communication protocol between test_controller.js and the driving |
| 7 * page are JSON encoded messages of the following form: | 7 * page are JSON encoded messages of the following form: |
| 8 * message = { | 8 * message = { |
| 9 * is_first_message: true/false, | 9 * is_first_message: true/false, |
| 10 * is_status_update: true/false, | 10 * is_status_update: true/false, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * { | 27 * { |
| 28 * 'type' : 'sync_exception' / 'window_onerror' / 'script_onerror' / 'print' | 28 * 'type' : 'sync_exception' / 'window_onerror' / 'script_onerror' / 'print' |
| 29 * 'window_compilationerror' / 'message_received' / 'dom' / 'debug' | 29 * 'window_compilationerror' / 'message_received' / 'dom' / 'debug' |
| 30 * 'value' : 'some content', | 30 * 'value' : 'some content', |
| 31 * 'timestamp' : TimestampInMs, | 31 * 'timestamp' : TimestampInMs, |
| 32 * } | 32 * } |
| 33 */ | 33 */ |
| 34 var recordedEventList = []; | 34 var recordedEventList = []; |
| 35 var timestampOfFirstEvent = null; | 35 var timestampOfFirstEvent = null; |
| 36 | 36 |
| 37 var STATUS_UPDATE_INTERVALL = 10000; | 37 var STATUS_UPDATE_INTERVAL = 10000; |
| 38 | 38 |
| 39 function getCurrentTimestamp() { | 39 function getCurrentTimestamp() { |
| 40 if (timestampOfFirstEvent == null) { | 40 if (timestampOfFirstEvent == null) { |
| 41 timestampOfFirstEvent = new Date().getTime(); | 41 timestampOfFirstEvent = new Date().getTime(); |
| 42 } | 42 } |
| 43 return (new Date().getTime() - timestampOfFirstEvent) / 1000.0; | 43 return (new Date().getTime() - timestampOfFirstEvent) / 1000.0; |
| 44 } | 44 } |
| 45 | 45 |
| 46 function stringifyEvent(event) { | 46 function stringifyEvent(event) { |
| 47 return JSON.stringify(event, null, 2); | 47 return JSON.stringify(event, null, 2); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 function notifyDone(testOutcome) { | 196 function notifyDone(testOutcome) { |
| 197 notifyUpdate(testOutcome, false, false, true); | 197 notifyUpdate(testOutcome, false, false, true); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Repeatedly send back the current status of this test. | 200 // Repeatedly send back the current status of this test. |
| 201 function sendStatusUpdate(isFirstMessage) { | 201 function sendStatusUpdate(isFirstMessage) { |
| 202 notifyUpdate('', isFirstMessage, true, false); | 202 notifyUpdate('', isFirstMessage, true, false); |
| 203 setTimeout(function() {sendStatusUpdate(false)}, STATUS_UPDATE_INTERVALL); | 203 setTimeout(function() {sendStatusUpdate(false)}, STATUS_UPDATE_INTERVAL); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // We call notifyStart here to notify the encapsulating browser. | 206 // We call notifyStart here to notify the encapsulating browser. |
| 207 recordEvent('debug', 'test_controller.js started'); | 207 recordEvent('debug', 'test_controller.js started'); |
| 208 sendStatusUpdate(true); | 208 sendStatusUpdate(true); |
| 209 | 209 |
| 210 function processMessage(msg) { | 210 function processMessage(msg) { |
| 211 // Filter out ShadowDOM polyfill messages which are random floats. | 211 // Filter out ShadowDOM polyfill messages which are random floats. |
| 212 if (msg != parseFloat(msg)) { | 212 if (msg != parseFloat(msg)) { |
| 213 recordEvent('message_received', '' + msg); | 213 recordEvent('message_received', '' + msg); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 dartPrint('dart-calling-main'); | 309 dartPrint('dart-calling-main'); |
| 310 try { | 310 try { |
| 311 main(); | 311 main(); |
| 312 } catch (e) { | 312 } catch (e) { |
| 313 recordEvent('sync_exception', 'Exception: ' + e + '\nStack: ' + e.stack); | 313 recordEvent('sync_exception', 'Exception: ' + e + '\nStack: ' + e.stack); |
| 314 notifyDone('FAIL'); | 314 notifyDone('FAIL'); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| 317 dartPrint('dart-main-done'); | 317 dartPrint('dart-main-done'); |
| 318 } | 318 } |
| OLD | NEW |