| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * Test controller logic - used by unit test harness to embed tests in | 6 * Test controller logic - used by unit test harness to embed tests in |
| 7 * DumpRenderTree. | 7 * DumpRenderTree. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 if (navigator.webkitStartDart) { | 10 if (navigator.webkitStartDart) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 function onReceive(e) { | 24 function onReceive(e) { |
| 25 processMessage(e.data); | 25 processMessage(e.data); |
| 26 } | 26 } |
| 27 | 27 |
| 28 if (window.layoutTestController) { | 28 if (window.layoutTestController) { |
| 29 window.layoutTestController.dumpAsText(); | 29 window.layoutTestController.dumpAsText(); |
| 30 window.layoutTestController.waitUntilDone(); | 30 window.layoutTestController.waitUntilDone(); |
| 31 } | 31 } |
| 32 window.addEventListener("message", onReceive, false); | 32 window.addEventListener("message", onReceive, false); |
| 33 | 33 |
| 34 function showErrorAndExit(message) { |
| 35 if (message) { |
| 36 var element = document.createElement('pre'); |
| 37 element.innerHTML = message; |
| 38 document.body.appendChild(element); |
| 39 } |
| 40 if (window.layoutTestController) { |
| 41 window.layoutTestController.notifyDone(); |
| 42 } |
| 43 } |
| 44 |
| 34 function onLoad(e) { | 45 function onLoad(e) { |
| 35 // needed for dartium compilation errors. | 46 // needed for dartium compilation errors. |
| 36 if (window.compilationError) { | 47 if (window.compilationError) { |
| 37 var element = document.createElement('pre'); | 48 showErrorAndExit(window.compilationError); |
| 38 element.innerHTML = window.compilationError; | |
| 39 document.body.appendChild(element); | |
| 40 window.layoutTestController.notifyDone(); | |
| 41 return; | |
| 42 } | 49 } |
| 43 } | 50 } |
| 44 | 51 |
| 45 window.addEventListener("DOMContentLoaded", onLoad, false); | 52 window.addEventListener("DOMContentLoaded", onLoad, false); |
| 53 |
| 54 // If nobody intercepts the error, finish the test. |
| 55 window.addEventListener("error", function(e) { |
| 56 // needed for dartium compilation errors. |
| 57 showErrorAndExit(e && e.message); |
| 58 }, false); |
| 59 |
| 60 document.onreadystatechange = function() { |
| 61 if (document.readyState != "loaded") return; |
| 62 // If 'startedDartTest' is not set, that means that the test did not have |
| 63 // a chance to load. This will happen when a load error occurs in the VM. |
| 64 // Give the machine time to start up. |
| 65 setTimeout(function() { |
| 66 // A window.postMessage might have been enqueued after this timeout. |
| 67 // Just sleep another time to give the browser the time to process the |
| 68 // posted message. |
| 69 setTimeout(function() { |
| 70 if (layoutTestController && !layoutTestController.startedDartTest) { |
| 71 layoutTestController.notifyDone(); |
| 72 } |
| 73 }, 0); |
| 74 }, 50); |
| 75 }; |
| OLD | NEW |