Chromium Code Reviews| Index: tools/testing/dart/browser_controller.dart |
| =================================================================== |
| --- tools/testing/dart/browser_controller.dart (revision 23967) |
| +++ tools/testing/dart/browser_controller.dart (working copy) |
| @@ -706,6 +706,7 @@ |
| } |
| return Future.wait(futures).then((values) { |
| testingServer.httpServer.close(); |
| + testingServer.errorReportingServer.close(); |
| printDoubleReportingTests(); |
| return !values.contains(false); |
| }); |
| @@ -741,6 +742,7 @@ |
| var testCount = 0; |
| var httpServer; |
| + var errorReportingServer; |
| bool underTermination = false; |
| bool useIframe = false; |
| @@ -785,8 +787,30 @@ |
| void errorHandler(e) { |
| if (!underTermination) print("Error occured in httpserver: $e"); |
| }; |
| + |
| httpServer.listen(handler, onError: errorHandler); |
| - return true; |
| + |
| + // Set up the error reporting server that enables us to send back |
| + // errors from the browser. |
| + return HttpServer.bind(local_ip, 0).then((createdReportServer) { |
| + errorReportingServer = createdReportServer; |
| + void errorReportingHandler(HttpRequest request) { |
| + StringBuffer buffer = new StringBuffer(); |
| + request.transform(new StringDecoder()).listen((data) { |
| + buffer.write(data); |
| + }, onDone: () { |
| + String back = buffer.toString(); |
| + request.response.headers.set("Access-Control-Allow-Origin", "*"); |
| + |
| + request.response.close(); |
| + DebugLogger.info("Error from browser on : " |
|
kustermann
2013/06/13 12:34:04
Make it DebugLogger.error.
ricow1
2013/06/13 12:39:54
Done.
|
| + "${request.uri.path}, data: $back"); |
|
kustermann
2013/06/13 12:34:04
Please catch errors on the "request.response.done/
ricow1
2013/06/13 12:39:54
Done.
|
| + }, onError: (error) { print(error); }); |
| + } |
| + errorReportingServer.listen(errorReportingHandler, |
| + onError: errorHandler); |
| + return true; |
| + }); |
|
kustermann
2013/06/13 12:34:04
indentation
ricow1
2013/06/13 12:39:54
Done.
|
| }); |
| } |
| @@ -827,6 +851,8 @@ |
| String getDriverPage(String browserId) { |
| + var errorReportingUrl = |
| + "http://$local_ip:${errorReportingServer.port}/$browserId"; |
| String driverContent = """ |
| <!DOCTYPE html><html> |
| <head> |
| @@ -864,7 +890,7 @@ |
| run(nextTask); |
| } |
| } else { |
| - // We are basically in trouble - do something clever. |
| + reportError('Could not contact the server and get a new task'); |
| } |
| } |
| } |
| @@ -890,6 +916,29 @@ |
| } |
| } |
| + window.onerror = function (message, url, lineNumber) { |
| + if (url) { |
| + reportError(url + ':' + lineNumber + ':' + message); |
| + } else { |
| + reportError(message); |
| + } |
| + } |
| + |
| + function reportError(msg) { |
| + var client = new XMLHttpRequest(); |
| + function handleReady() { |
| + if (this.readyState == this.DONE && this.status != 200) { |
| + // We could not report, pop up to notify if running interactively. |
| + alert(this.status); |
| + } |
| + } |
| + client.onreadystatechange = handleReady; |
| + client.open('POST', '$errorReportingUrl?test=1'); |
| + client.setRequestHeader('Content-type', |
| + 'application/x-www-form-urlencoded'); |
| + client.send(msg); |
| + } |
| + |
| function reportMessage(msg) { |
| if (msg == 'STARTING') { |
| did_start = true; |
| @@ -898,9 +947,13 @@ |
| var client = new XMLHttpRequest(); |
| function handleReady() { |
| if (this.readyState == this.DONE) { |
| - if (last_reported_id != current_id && did_start) { |
| - getNextTask(); |
| - last_reported_id = current_id; |
| + if (this.status == 200) { |
| + if (last_reported_id != current_id && did_start) { |
| + getNextTask(); |
| + last_reported_id = current_id; |
| + } |
| + } else { |
| + reportError('Error sending result to server'); |
| } |
| } |
| } |
| @@ -914,8 +967,6 @@ |
| client.setRequestHeader('Content-type', |
| 'application/x-www-form-urlencoded'); |
| client.send(msg); |
| - // TODO(ricow) add error handling to somehow report the fact that |
| - // we could not send back a result. |
| } |
| function messageHandler(e) { |