| 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 library browser; | 4 library browser; |
| 5 | 5 |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:convert" show LineSplitter, UTF8; | 7 import "dart:convert" show LineSplitter, UTF8; |
| 8 import "dart:core"; | 8 import "dart:core"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 // We don't add urls to the cache until we have run it. | 757 // We don't add urls to the cache until we have run it. |
| 758 Map<int, String> testCache = new Map<int, String>(); | 758 Map<int, String> testCache = new Map<int, String>(); |
| 759 Map<int, String> doubleReportingOutputs = new Map<int, String>(); | 759 Map<int, String> doubleReportingOutputs = new Map<int, String>(); |
| 760 | 760 |
| 761 BrowserTestingServer testingServer; | 761 BrowserTestingServer testingServer; |
| 762 | 762 |
| 763 BrowserTestRunner(this.globalConfiguration, | 763 BrowserTestRunner(this.globalConfiguration, |
| 764 this.localIp, | 764 this.localIp, |
| 765 this.browserName, | 765 this.browserName, |
| 766 this.maxNumBrowsers, | 766 this.maxNumBrowsers, |
| 767 {bool this.checkedMode: false}); | 767 {bool this.checkedMode: false, |
| 768 BrowserTestingServer this.testingServer}); |
| 768 | 769 |
| 769 Future<bool> start() { | 770 Future<bool> start() { |
| 770 // If [browserName] doesn't support opening new windows, we use new iframes | 771 // If [browserName] doesn't support opening new windows, we use new iframes |
| 771 // instead. | 772 // instead. |
| 772 bool useIframe = | 773 bool useIframe = |
| 773 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); | 774 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); |
| 774 testingServer = new BrowserTestingServer( | 775 if (testingServer == null) { |
| 775 globalConfiguration, localIp, useIframe); | 776 testingServer = new BrowserTestingServer( |
| 777 globalConfiguration, localIp, useIframe); |
| 778 } |
| 776 return testingServer.start().then((_) { | 779 return testingServer.start().then((_) { |
| 777 testingServer.testDoneCallBack = handleResults; | 780 testingServer.testDoneCallBack = handleResults; |
| 778 testingServer.testStatusUpdateCallBack = handleStatusUpdate; | 781 testingServer.testStatusUpdateCallBack = handleStatusUpdate; |
| 779 testingServer.testStartedCallBack = handleStarted; | 782 testingServer.testStartedCallBack = handleStarted; |
| 780 testingServer.nextTestCallBack = getNextTest; | 783 testingServer.nextTestCallBack = getNextTest; |
| 781 return getBrowsers().then((browsers) { | 784 return getBrowsers().then((browsers) { |
| 782 var futures = []; | 785 var futures = []; |
| 783 for (var browser in browsers) { | 786 for (var browser in browsers) { |
| 784 var url = testingServer.getDriverUrl(browser.id); | 787 var url = testingServer.getDriverUrl(browser.id); |
| 785 var future = browser.start(url).then((success) { | 788 var future = browser.start(url).then((success) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 // /favicon.ico requests | 1155 // /favicon.ico requests |
| 1153 } | 1156 } |
| 1154 request.response.write(textResponse); | 1157 request.response.write(textResponse); |
| 1155 request.listen((_) {}, onDone: request.response.close); | 1158 request.listen((_) {}, onDone: request.response.close); |
| 1156 request.response.done.catchError((error) { | 1159 request.response.done.catchError((error) { |
| 1157 if (!underTermination) { | 1160 if (!underTermination) { |
| 1158 print("URI ${request.uri}"); | 1161 print("URI ${request.uri}"); |
| 1159 print("Textresponse $textResponse"); | 1162 print("Textresponse $textResponse"); |
| 1160 throw "Error returning content to browser: $error"; | 1163 throw "Error returning content to browser: $error"; |
| 1161 } | 1164 } |
| 1162 }); | 1165 }); |
| 1163 } | 1166 } |
| 1164 void errorHandler(e) { | 1167 void errorHandler(e) { |
| 1165 if (!underTermination) print("Error occured in httpserver: $e"); | 1168 if (!underTermination) print("Error occured in httpserver: $e"); |
| 1166 }; | 1169 }; |
| 1167 | 1170 |
| 1168 httpServer.listen(handler, onError: errorHandler); | 1171 httpServer.listen(handler, onError: errorHandler); |
| 1169 | 1172 |
| 1170 // Set up the error reporting server that enables us to send back | 1173 // Set up the error reporting server that enables us to send back |
| 1171 // errors from the browser. | 1174 // errors from the browser. |
| 1172 port = globalConfiguration['test_driver_error_port']; | 1175 port = globalConfiguration['test_driver_error_port']; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 Dart test driver, number of tests: <div id="number"></div><br> | 1445 Dart test driver, number of tests: <div id="number"></div><br> |
| 1443 Currently executing: <div id="currently_executing"></div><br> | 1446 Currently executing: <div id="currently_executing"></div><br> |
| 1444 Unhandled error: <div id="unhandled_error"></div> | 1447 Unhandled error: <div id="unhandled_error"></div> |
| 1445 <iframe id="embedded_iframe"></iframe> | 1448 <iframe id="embedded_iframe"></iframe> |
| 1446 </body> | 1449 </body> |
| 1447 </html> | 1450 </html> |
| 1448 """; | 1451 """; |
| 1449 return driverContent; | 1452 return driverContent; |
| 1450 } | 1453 } |
| 1451 } | 1454 } |
| OLD | NEW |