Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: lib/unittest/test_controller.js

Issue 10627004: Listen for on.error events in test_controller.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: addressing comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/testing/dart/browser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/test_controller.js
diff --git a/lib/unittest/test_controller.js b/lib/unittest/test_controller.js
index 988bfe10fd704039b33116d3ed407854c6d99ca7..85e2b94338576ee93c8be22cd5d55da3606f1955 100644
--- a/lib/unittest/test_controller.js
+++ b/lib/unittest/test_controller.js
@@ -31,15 +31,45 @@ if (window.layoutTestController) {
}
window.addEventListener("message", onReceive, false);
-function onLoad(e) {
- // needed for dartium compilation errors.
- if (window.compilationError) {
+function showErrorAndExit(message) {
+ if (message) {
var element = document.createElement('pre');
- element.innerHTML = window.compilationError;
+ element.innerHTML = message;
document.body.appendChild(element);
+ }
+ if (window.layoutTestController) {
window.layoutTestController.notifyDone();
- return;
+ }
+}
+
+function onLoad(e) {
+ // needed for dartium compilation errors.
+ if (window.compilationError) {
+ showErrorAndExit(window.compilationError);
}
}
window.addEventListener("DOMContentLoaded", onLoad, false);
+
+// If nobody intercepts the error, finish the test.
+window.addEventListener("error", function(e) {
+ // needed for dartium compilation errors.
+ showErrorAndExit(e && e.message);
+}, false);
+
+document.onreadystatechange = function() {
+ if (document.readyState != "loaded") return;
+ // If 'startedDartTest' is not set, that means that the test did not have
+ // a chance to load. This will happen when a load error occurs in the VM.
+ // Give the machine time to start up.
+ setTimeout(function() {
+ // A window.postMessage might have been enqueued after this timeout.
+ // Just sleep another time to give the browser the time to process the
+ // posted message.
+ setTimeout(function() {
+ if (layoutTestController && !layoutTestController.startedDartTest) {
+ layoutTestController.notifyDone();
+ }
+ }, 0);
+ }, 50);
+};
« no previous file with comments | « no previous file | tools/testing/dart/browser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698