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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/dart/browser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 };
OLDNEW
« 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