Chromium Code Reviews| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 notifyDone('FAIL'); | 102 notifyDone('FAIL'); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // testRunner is provided by content shell. | 105 // testRunner is provided by content shell. |
| 106 // It is not available in browser tests. | 106 // It is not available in browser tests. |
| 107 var testRunner = window.testRunner || window.layoutTestController; | 107 var testRunner = window.testRunner || window.layoutTestController; |
| 108 var isContentShell = testRunner; | 108 var isContentShell = testRunner; |
| 109 | 109 |
| 110 var waitForDone = false; | 110 var waitForDone = false; |
| 111 | 111 |
| 112 var driverWindowCached = false; | |
| 113 var driverWindow; | |
| 114 var reportingDriverWindowError = false; | |
| 115 | |
| 112 // Returns the driving window object if available | 116 // Returns the driving window object if available |
| 117 // This function occasionally returns null instead of the | |
| 118 // parent on Android content shell, so we cache the value | |
| 119 // to get a consistent answer. | |
| 113 function getDriverWindow() { | 120 function getDriverWindow() { |
| 114 if (window != window.parent) { | 121 if (window != window.parent) { |
| 115 // We're running in an iframe. | 122 // We're running in an iframe. |
| 116 return window.parent; | 123 result = window.parent; |
| 117 } else if (window.opener) { | 124 } else if (window.opener) { |
| 118 // We were opened by another window. | 125 // We were opened by another window. |
| 119 return window.opener; | 126 result = window.opener; |
| 127 } else { | |
| 128 result = null; | |
| 120 } | 129 } |
| 121 return null; | 130 if (driverWindowCached) { |
| 131 if (result != driverWindow) { | |
| 132 recordEvent('debug', 'Driver windows changed: was null == ' + | |
| 133 (driverWindow == null) + ', is null == ' + (result == null)); | |
| 134 // notifyDone calls back into this function multiple times. Avoid loop. | |
| 135 if (!reportingDriverWindowError) { | |
|
ricow1
2014/08/14 15:24:10
I assume this is to get us to fail explicitly to d
| |
| 136 reportingDriverWindowError = true; | |
| 137 notifyDone('FAIL'); | |
| 138 } | |
| 139 } | |
| 140 } else { | |
| 141 driverWindowCached = true; | |
| 142 driverWindow = result; | |
| 143 } | |
| 144 return driverWindow; | |
| 122 } | 145 } |
| 123 | 146 |
| 124 function usingBrowserController() { | 147 function usingBrowserController() { |
| 125 return getDriverWindow() != null; | 148 return getDriverWindow() != null; |
| 126 } | 149 } |
| 127 | 150 |
| 128 function buildDomEvent() { | 151 function buildDomEvent() { |
| 129 return { | 152 return { |
| 130 type: 'dom', | 153 type: 'dom', |
| 131 value: '' + window.document.documentElement.innerHTML, | 154 value: '' + window.document.documentElement.innerHTML, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 dartPrint('dart-calling-main'); | 309 dartPrint('dart-calling-main'); |
| 287 try { | 310 try { |
| 288 main(); | 311 main(); |
| 289 } catch (e) { | 312 } catch (e) { |
| 290 recordEvent('sync_exception', 'Exception: ' + e + '\nStack: ' + e.stack); | 313 recordEvent('sync_exception', 'Exception: ' + e + '\nStack: ' + e.stack); |
| 291 notifyDone('FAIL'); | 314 notifyDone('FAIL'); |
| 292 return; | 315 return; |
| 293 } | 316 } |
| 294 dartPrint('dart-main-done'); | 317 dartPrint('dart-main-done'); |
| 295 } | 318 } |
| OLD | NEW |