Chromium Code Reviews| 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 |
|
Bill Hesse
2016/04/25 08:20:18
This is not rebased to the current version of brow
ahe
2016/05/24 08:44:42
Done.
| |
| 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, JSON; | 7 import "dart:convert" show LineSplitter, UTF8, JSON; |
| 8 import "dart:core"; | 8 import "dart:core"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| 11 import 'android.dart'; | 11 import 'android.dart'; |
| 12 import 'http_server.dart'; | 12 import 'http_server.dart'; |
| 13 import 'path.dart'; | 13 import 'path.dart'; |
| 14 import 'utils.dart'; | 14 import 'utils.dart'; |
| 15 | 15 |
| 16 import 'reset_safari.dart' show | |
| 17 killAndResetSafari; | |
| 18 | |
| 16 class BrowserOutput { | 19 class BrowserOutput { |
| 17 final StringBuffer stdout = new StringBuffer(); | 20 final StringBuffer stdout = new StringBuffer(); |
| 18 final StringBuffer stderr = new StringBuffer(); | 21 final StringBuffer stderr = new StringBuffer(); |
| 19 final StringBuffer eventLog = new StringBuffer(); | 22 final StringBuffer eventLog = new StringBuffer(); |
| 20 } | 23 } |
| 21 | 24 |
| 22 /** Class describing the interface for communicating with browsers. */ | 25 /** Class describing the interface for communicating with browsers. */ |
| 23 abstract class Browser { | 26 abstract class Browser { |
| 24 BrowserOutput _allBrowserOutput = new BrowserOutput(); | 27 BrowserOutput _allBrowserOutput = new BrowserOutput(); |
| 25 BrowserOutput _testBrowserOutput = new BrowserOutput(); | 28 BrowserOutput _testBrowserOutput = new BrowserOutput(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 return browser; | 92 return browser; |
| 90 } | 93 } |
| 91 | 94 |
| 92 static const List<String> SUPPORTED_BROWSERS = | 95 static const List<String> SUPPORTED_BROWSERS = |
| 93 const ['safari', 'ff', 'firefox', 'chrome', 'ie9', 'ie10', | 96 const ['safari', 'ff', 'firefox', 'chrome', 'ie9', 'ie10', |
| 94 'ie11', 'dartium']; | 97 'ie11', 'dartium']; |
| 95 | 98 |
| 96 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = | 99 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = |
| 97 const ['ie11', 'ie10']; | 100 const ['ie11', 'ie10']; |
| 98 | 101 |
| 102 /// If [browserName] doesn't support Window.open, we use iframes instead. | |
| 103 static bool requiresIframe(String browserName) { | |
| 104 return !BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); | |
| 105 } | |
| 106 | |
| 107 static bool requiresFocus(String browserName) { | |
| 108 return browserName == "safari"; | |
| 109 } | |
| 110 | |
| 99 // TODO(kustermann): add standard support for chrome on android | 111 // TODO(kustermann): add standard support for chrome on android |
| 100 static bool supportedBrowser(String name) { | 112 static bool supportedBrowser(String name) { |
| 101 return SUPPORTED_BROWSERS.contains(name); | 113 return SUPPORTED_BROWSERS.contains(name); |
| 102 } | 114 } |
| 103 | 115 |
| 104 void _logEvent(String event) { | 116 void _logEvent(String event) { |
| 105 String toLog = "$this ($id) - $event \n"; | 117 String toLog = "$this ($id) - $event \n"; |
| 106 if (debugPrint) print("usageLog: $toLog"); | 118 if (debugPrint) print("usageLog: $toLog"); |
| 107 if (logger != null) logger(toLog); | 119 if (logger != null) logger(toLog); |
| 108 | 120 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 Future<bool> start(String url); | 274 Future<bool> start(String url); |
| 263 } | 275 } |
| 264 | 276 |
| 265 class Safari extends Browser { | 277 class Safari extends Browser { |
| 266 /** | 278 /** |
| 267 * We get the safari version by parsing a version file | 279 * We get the safari version by parsing a version file |
| 268 */ | 280 */ |
| 269 static const String versionFile = | 281 static const String versionFile = |
| 270 "/Applications/Safari.app/Contents/version.plist"; | 282 "/Applications/Safari.app/Contents/version.plist"; |
| 271 | 283 |
| 272 /** | 284 static const String safariBundleLocation = "/Applications/Safari.app/"; |
| 273 * Directories where safari stores state. We delete these if the deleteCache | |
| 274 * is set | |
| 275 */ | |
| 276 static const List<String> CACHE_DIRECTORIES = | |
| 277 const ["Library/Caches/com.apple.Safari", | |
| 278 "Library/Safari", | |
| 279 "Library/Saved Application State/com.apple.Safari.savedState", | |
| 280 "Library/Caches/Metadata/Safari"]; | |
| 281 | |
| 282 | 285 |
| 283 Future<bool> allowPopUps() { | 286 Future<bool> allowPopUps() { |
| 284 var command = "defaults"; | 287 // DO NOT SUBMIT. |
|
Bill Hesse
2016/04/25 08:20:18
This comment says "do not submit". Should we remo
ahe
2016/05/24 08:44:42
Done.
| |
| 285 var args = ["write", "com.apple.safari", | 288 return new Future.value(true); |
| 286 "com.apple.Safari.ContentPageGroupIdentifier." | |
| 287 "WebKit2JavaScriptCanOpenWindowsAutomatically", | |
| 288 "1"]; | |
| 289 return Process.run(command, args).then((result) { | |
| 290 if (result.exitCode != 0) { | |
| 291 _logEvent("Could not disable pop-up blocking for safari"); | |
| 292 return false; | |
| 293 } | |
| 294 return true; | |
| 295 }); | |
| 296 } | |
| 297 | |
| 298 Future<bool> deleteIfExists(Iterator<String> paths) { | |
| 299 if (!paths.moveNext()) return new Future.value(true); | |
| 300 Directory directory = new Directory(paths.current); | |
| 301 return directory.exists().then((exists) { | |
| 302 if (exists) { | |
| 303 _logEvent("Deleting ${paths.current}"); | |
| 304 return directory.delete(recursive: true) | |
| 305 » .then((_) => deleteIfExists(paths)) | |
| 306 » .catchError((error) { | |
| 307 » _logEvent("Failure trying to delete ${paths.current}: $error"); | |
| 308 » return false; | |
| 309 » }); | |
| 310 } else { | |
| 311 _logEvent("${paths.current} is not present"); | |
| 312 return deleteIfExists(paths); | |
| 313 } | |
| 314 }); | |
| 315 } | 289 } |
| 316 | 290 |
| 317 // Clears the cache if the static deleteCache flag is set. | 291 // Clears the cache if the static deleteCache flag is set. |
| 318 // Returns false if the command to actually clear the cache did not complete. | 292 // Returns false if the command to actually clear the cache did not complete. |
| 319 Future<bool> clearCache() { | 293 Future<bool> clearCache() async { |
| 320 if (!Browser.deleteCache) return new Future.value(true); | 294 if (!Browser.deleteCache) return true; |
| 321 var home = Platform.environment['HOME']; | 295 |
| 322 Iterator iterator = CACHE_DIRECTORIES.map((s) => "$home/$s").iterator; | 296 Completer completer = new Completer(); |
| 323 return deleteIfExists(iterator); | 297 handleUncaughtError(error, StackTrace stackTrace) { |
| 298 if (!completer.isCompleted) { | |
| 299 completer.completeError(error, stackTrace); | |
| 300 } else { | |
| 301 throw new AsyncError(error, stackTrace); | |
| 302 } | |
| 303 } | |
| 304 Zone parent = Zone.current; | |
|
Bill Hesse
2016/04/25 08:20:18
Add a comment for why we are using the zone - is i
ahe
2016/05/24 08:44:42
Done.
| |
| 305 ZoneSpecification specification = new ZoneSpecification( | |
| 306 print: (Zone self, ZoneDelegate delegate, Zone zone, String line) { | |
| 307 delegate.run(parent, () { | |
| 308 _logEvent(line); | |
| 309 }); | |
| 310 }); | |
| 311 Future zoneWrapper() { | |
| 312 Uri safariUri = Uri.base.resolve(safariBundleLocation); | |
| 313 return new Future(() => killAndResetSafari(bundle: safariUri)) | |
| 314 .then(completer.complete); | |
| 315 } | |
| 316 | |
| 317 runZoned( | |
| 318 zoneWrapper, zoneSpecification: specification, | |
| 319 onError: handleUncaughtError); | |
| 320 | |
| 321 try { | |
| 322 await completer.future; | |
| 323 return true; | |
| 324 } catch (error, st) { | |
| 325 _logEvent("Unable to reset Safari: $error$st"); | |
| 326 return false; | |
| 327 } | |
| 324 } | 328 } |
| 325 | 329 |
| 326 Future<String> getVersion() { | 330 Future<String> getVersion() { |
| 327 /** | 331 /** |
| 328 * Example of the file: | 332 * Example of the file: |
| 329 * <?xml version="1.0" encoding="UTF-8"?> | 333 * <?xml version="1.0" encoding="UTF-8"?> |
| 330 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd"> | 334 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd"> |
| 331 * <plist version="1.0"> | 335 * <plist version="1.0"> |
| 332 * <dict> | 336 * <dict> |
| 333 * <key>BuildVersion</key> | 337 * <key>BuildVersion</key> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 if (!cleared) { | 378 if (!cleared) { |
| 375 _logEvent("Could not clear cache"); | 379 _logEvent("Could not clear cache"); |
| 376 return false; | 380 return false; |
| 377 } | 381 } |
| 378 // Get the version and log that. | 382 // Get the version and log that. |
| 379 return getVersion().then((version) { | 383 return getVersion().then((version) { |
| 380 _logEvent("Got version: $version"); | 384 _logEvent("Got version: $version"); |
| 381 return Directory.systemTemp.createTemp().then((userDir) { | 385 return Directory.systemTemp.createTemp().then((userDir) { |
| 382 _cleanup = () { userDir.deleteSync(recursive: true); }; | 386 _cleanup = () { userDir.deleteSync(recursive: true); }; |
| 383 _createLaunchHTML(userDir.path, url); | 387 _createLaunchHTML(userDir.path, url); |
| 384 var args = ["${userDir.path}/launch.html"]; | 388 var args = [ |
| 385 return startBrowser(_binary, args); | 389 "-d", "-i", "-m", "-s", "-u", _binary, |
| 390 "${userDir.path}/launch.html"]; | |
| 391 return startBrowser("/usr/bin/caffeinate", args); | |
| 386 }); | 392 }); |
| 387 }).catchError((error) { | 393 }).catchError((error) { |
| 388 _logEvent("Running $_binary --version failed with $error"); | 394 _logEvent("Running $_binary --version failed with $error"); |
| 389 return false; | 395 return false; |
| 390 }); | 396 }); |
| 391 }); | 397 }); |
| 392 }); | 398 }); |
| 393 } | 399 } |
| 394 | 400 |
| 395 String toString() => "Safari"; | 401 String toString() => "Safari"; |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 * whenever a test completes. | 855 * whenever a test completes. |
| 850 */ | 856 */ |
| 851 class BrowserTestRunner { | 857 class BrowserTestRunner { |
| 852 static const int MAX_NEXT_TEST_TIMEOUTS = 10; | 858 static const int MAX_NEXT_TEST_TIMEOUTS = 10; |
| 853 static const Duration NEXT_TEST_TIMEOUT = const Duration(seconds: 60); | 859 static const Duration NEXT_TEST_TIMEOUT = const Duration(seconds: 60); |
| 854 static const Duration RESTART_BROWSER_INTERVAL = const Duration(seconds: 60); | 860 static const Duration RESTART_BROWSER_INTERVAL = const Duration(seconds: 60); |
| 855 | 861 |
| 856 final Map configuration; | 862 final Map configuration; |
| 857 | 863 |
| 858 final String localIp; | 864 final String localIp; |
| 859 String browserName; | 865 final String browserName; |
| 860 final int maxNumBrowsers; | 866 final int maxNumBrowsers; |
| 861 bool checkedMode; | 867 bool checkedMode; |
| 862 // Used to send back logs from the browser (start, stop etc) | 868 // Used to send back logs from the browser (start, stop etc) |
| 863 Function logger; | 869 Function logger; |
| 864 int browserIdCount = 0; | 870 int browserIdCount = 0; |
| 865 | 871 |
| 866 bool underTermination = false; | 872 bool underTermination = false; |
| 867 int numBrowserGetTestTimeouts = 0; | 873 int numBrowserGetTestTimeouts = 0; |
| 868 | 874 |
| 869 List<BrowserTest> testQueue = new List<BrowserTest>(); | 875 List<BrowserTest> testQueue = new List<BrowserTest>(); |
| 870 Map<String, BrowserTestingStatus> browserStatus = | 876 Map<String, BrowserTestingStatus> browserStatus = |
| 871 new Map<String, BrowserTestingStatus>(); | 877 new Map<String, BrowserTestingStatus>(); |
| 872 | 878 |
| 873 var adbDeviceMapping = new Map<String, AdbDevice>(); | 879 var adbDeviceMapping = new Map<String, AdbDevice>(); |
| 874 // This cache is used to guarantee that we never see double reporting. | 880 // This cache is used to guarantee that we never see double reporting. |
| 875 // If we do we need to provide developers with this information. | 881 // If we do we need to provide developers with this information. |
| 876 // We don't add urls to the cache until we have run it. | 882 // We don't add urls to the cache until we have run it. |
| 877 Map<int, String> testCache = new Map<int, String>(); | 883 Map<int, String> testCache = new Map<int, String>(); |
| 878 Map<int, String> doubleReportingOutputs = new Map<int, String>(); | 884 Map<int, String> doubleReportingOutputs = new Map<int, String>(); |
| 879 | 885 |
| 880 BrowserTestingServer testingServer; | 886 final BrowserTestingServer testingServer; |
| 881 | 887 |
| 882 /** | 888 /** |
| 883 * The TestRunner takes the testingServer in as a constructor parameter in | 889 * The TestRunner takes the testingServer in as a constructor parameter in |
| 884 * case we wish to have a testing server with different behavior (such as the | 890 * case we wish to have a testing server with different behavior (such as the |
|
Bill Hesse
2016/04/25 08:20:18
If we are removing the testingServer argument, the
ahe
2016/05/24 08:44:42
Done.
| |
| 885 * case for performance testing. | 891 * case for performance testing. |
| 886 */ | 892 */ |
| 887 BrowserTestRunner(this.configuration, | 893 BrowserTestRunner( |
| 888 this.localIp, | 894 Map configuration, |
| 889 this.browserName, | 895 String localIp, |
| 890 this.maxNumBrowsers, | 896 String browserName, |
| 891 {BrowserTestingServer this.testingServer}) { | 897 this.maxNumBrowsers) |
| 892 checkedMode = configuration['checked']; | 898 : configuration = configuration, |
| 893 } | 899 localIp = localIp, |
| 900 browserName = browserName, | |
| 901 checkedMode = configuration['checked'], | |
| 902 testingServer = new BrowserTestingServer( | |
| 903 configuration, localIp, | |
| 904 Browser.requiresIframe(browserName), | |
| 905 Browser.requiresFocus(browserName)); | |
| 894 | 906 |
| 895 Future<bool> start() { | 907 Future<bool> start() { |
| 896 // If [browserName] doesn't support opening new windows, we use new iframes | |
| 897 // instead. | |
| 898 bool useIframe = | |
| 899 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); | |
| 900 if (testingServer == null) { | |
| 901 testingServer = new BrowserTestingServer( | |
| 902 configuration, localIp, useIframe); | |
| 903 } | |
| 904 return testingServer.start().then((_) { | 908 return testingServer.start().then((_) { |
| 905 testingServer.testDoneCallBack = handleResults; | 909 testingServer.testDoneCallBack = handleResults; |
| 906 testingServer.testStatusUpdateCallBack = handleStatusUpdate; | 910 testingServer.testStatusUpdateCallBack = handleStatusUpdate; |
| 907 testingServer.testStartedCallBack = handleStarted; | 911 testingServer.testStartedCallBack = handleStarted; |
| 908 testingServer.nextTestCallBack = getNextTest; | 912 testingServer.nextTestCallBack = getNextTest; |
| 909 return getBrowsers().then((browsers) { | 913 return getBrowsers().then((browsers) { |
| 910 var futures = []; | 914 var futures = []; |
| 911 for (var browser in browsers) { | 915 for (var browser in browsers) { |
| 912 var url = testingServer.getDriverUrl(browser.id); | 916 var url = testingServer.getDriverUrl(browser.id); |
| 913 var future = browser.start(url).then((success) { | 917 var future = browser.start(url).then((success) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1296 /// and run tests ... | 1300 /// and run tests ... |
| 1297 /// GET /next_test/BROWSER_ID -- returns "WAIT" "TERMINATE" or "url#id" | 1301 /// GET /next_test/BROWSER_ID -- returns "WAIT" "TERMINATE" or "url#id" |
| 1298 /// where url is the test to run, and id is the id of the test. | 1302 /// where url is the test to run, and id is the id of the test. |
| 1299 /// If there are currently no available tests the waitSignal is send | 1303 /// If there are currently no available tests the waitSignal is send |
| 1300 /// back. If we are in the process of terminating the terminateSignal | 1304 /// back. If we are in the process of terminating the terminateSignal |
| 1301 /// is send back and the browser will stop requesting new tasks. | 1305 /// is send back and the browser will stop requesting new tasks. |
| 1302 /// POST /report/BROWSER_ID?id=NUM -- sends back the dom of the executed | 1306 /// POST /report/BROWSER_ID?id=NUM -- sends back the dom of the executed |
| 1303 /// test | 1307 /// test |
| 1304 | 1308 |
| 1305 final String localIp; | 1309 final String localIp; |
| 1310 final bool useIframe; | |
| 1311 final bool requiresFocus; | |
| 1306 | 1312 |
| 1307 static const String driverPath = "/driver"; | 1313 static const String driverPath = "/driver"; |
| 1308 static const String nextTestPath = "/next_test"; | 1314 static const String nextTestPath = "/next_test"; |
| 1309 static const String reportPath = "/report"; | 1315 static const String reportPath = "/report"; |
| 1310 static const String statusUpdatePath = "/status_update"; | 1316 static const String statusUpdatePath = "/status_update"; |
| 1311 static const String startedPath = "/started"; | 1317 static const String startedPath = "/started"; |
| 1312 static const String waitSignal = "WAIT"; | 1318 static const String waitSignal = "WAIT"; |
| 1313 static const String terminateSignal = "TERMINATE"; | 1319 static const String terminateSignal = "TERMINATE"; |
| 1314 | 1320 |
| 1315 var testCount = 0; | 1321 var testCount = 0; |
| 1316 var errorReportingServer; | 1322 var errorReportingServer; |
| 1317 bool underTermination = false; | 1323 bool underTermination = false; |
| 1318 bool useIframe = false; | |
| 1319 | 1324 |
| 1320 Function testDoneCallBack; | 1325 Function testDoneCallBack; |
| 1321 Function testStatusUpdateCallBack; | 1326 Function testStatusUpdateCallBack; |
| 1322 Function testStartedCallBack; | 1327 Function testStartedCallBack; |
| 1323 Function nextTestCallBack; | 1328 Function nextTestCallBack; |
| 1324 | 1329 |
| 1325 BrowserTestingServer(this.configuration, this.localIp, this.useIframe); | 1330 BrowserTestingServer( |
| 1331 this.configuration, this.localIp, this.useIframe, this.requiresFocus); | |
| 1326 | 1332 |
| 1327 Future start() { | 1333 Future start() { |
| 1328 var test_driver_error_port = configuration['test_driver_error_port']; | 1334 var test_driver_error_port = configuration['test_driver_error_port']; |
| 1329 return HttpServer.bind(localIp, test_driver_error_port) | 1335 return HttpServer.bind(localIp, test_driver_error_port) |
| 1330 .then(setupErrorServer) | 1336 .then(setupErrorServer) |
| 1331 .then(setupDispatchingServer); | 1337 .then(setupDispatchingServer); |
| 1332 } | 1338 } |
| 1333 | 1339 |
| 1334 void setupErrorServer(HttpServer server) { | 1340 void setupErrorServer(HttpServer server) { |
| 1335 errorReportingServer = server; | 1341 errorReportingServer = server; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 }); | 1385 }); |
| 1380 server.addHandler(startedPath, (HttpRequest request) { | 1386 server.addHandler(startedPath, (HttpRequest request) { |
| 1381 noCache(request); | 1387 noCache(request); |
| 1382 handleStarted(request, browserId(request, startedPath), | 1388 handleStarted(request, browserId(request, startedPath), |
| 1383 testId(request)); | 1389 testId(request)); |
| 1384 }); | 1390 }); |
| 1385 | 1391 |
| 1386 makeSendPageHandler(String prefix) => (HttpRequest request) { | 1392 makeSendPageHandler(String prefix) => (HttpRequest request) { |
| 1387 noCache(request); | 1393 noCache(request); |
| 1388 var textResponse = ""; | 1394 var textResponse = ""; |
| 1395 bool isStartup = false; | |
| 1389 if (prefix == driverPath) { | 1396 if (prefix == driverPath) { |
| 1397 isStartup = true; | |
| 1390 textResponse = getDriverPage(browserId(request, prefix)); | 1398 textResponse = getDriverPage(browserId(request, prefix)); |
| 1391 request.response.headers.set('Content-Type', 'text/html'); | 1399 request.response.headers.set('Content-Type', 'text/html'); |
| 1392 } | 1400 } |
| 1393 if (prefix == nextTestPath) { | 1401 if (prefix == nextTestPath) { |
| 1394 textResponse = getNextTest(browserId(request, prefix)); | 1402 textResponse = getNextTest(browserId(request, prefix)); |
| 1395 request.response.headers.set('Content-Type', 'text/plain'); | 1403 request.response.headers.set('Content-Type', 'text/plain'); |
| 1396 } | 1404 } |
| 1397 request.response.write(textResponse); | 1405 request.response.write(textResponse); |
| 1398 request.listen((_) {}, onDone: request.response.close); | 1406 closeResponse(_) { |
| 1407 // Ignoring the returned closure as it returns the 'done' future which | |
| 1408 // alread has catchError installed (see below). | |
| 1409 request.response.close(); | |
| 1410 } | |
| 1411 request.listen((_) {}, onDone: () { | |
| 1412 if (isStartup && requiresFocus) { | |
|
Bill Hesse
2016/04/25 08:20:19
Could we put this into the BrowserController objec
ahe
2016/05/24 08:44:42
Done.
| |
| 1413 Process.run( | |
| 1414 "/usr/bin/osascript", | |
| 1415 ['-e', 'tell application "Safari" to activate']) | |
| 1416 .then(closeResponse); | |
| 1417 } else { | |
| 1418 closeResponse(null); | |
| 1419 } | |
| 1420 }); | |
| 1399 request.response.done.catchError((error) { | 1421 request.response.done.catchError((error) { |
| 1400 if (!underTermination) { | 1422 if (!underTermination) { |
| 1401 print("URI ${request.uri}"); | 1423 print("URI ${request.uri}"); |
| 1402 print("Textresponse $textResponse"); | 1424 print("Textresponse $textResponse"); |
| 1403 throw "Error returning content to browser: $error"; | 1425 throw "Error returning content to browser: $error"; |
| 1404 } | 1426 } |
| 1405 }); | 1427 }); |
| 1406 }; | 1428 }; |
| 1407 server.addHandler(driverPath, makeSendPageHandler(driverPath)); | 1429 server.addHandler(driverPath, makeSendPageHandler(driverPath)); |
| 1408 server.addHandler(nextTestPath, makeSendPageHandler(nextTestPath)); | 1430 server.addHandler(nextTestPath, makeSendPageHandler(nextTestPath)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1455 "produce driver url"); | 1477 "produce driver url"); |
| 1456 exit(1); | 1478 exit(1); |
| 1457 // This should never happen - exit immediately; | 1479 // This should never happen - exit immediately; |
| 1458 } | 1480 } |
| 1459 var port = configuration['_servers_'].port; | 1481 var port = configuration['_servers_'].port; |
| 1460 return "http://$localIp:$port/driver/$browserId"; | 1482 return "http://$localIp:$port/driver/$browserId"; |
| 1461 } | 1483 } |
| 1462 | 1484 |
| 1463 | 1485 |
| 1464 String getDriverPage(String browserId) { | 1486 String getDriverPage(String browserId) { |
| 1487 | |
|
Bill Hesse
2016/04/25 08:20:19
I think this blank line should go. Do we run this
ahe
2016/05/24 08:44:42
Done.
| |
| 1465 var errorReportingUrl = | 1488 var errorReportingUrl = |
| 1466 "http://$localIp:${errorReportingServer.port}/$browserId"; | 1489 "http://$localIp:${errorReportingServer.port}/$browserId"; |
| 1467 String driverContent = """ | 1490 String driverContent = """ |
| 1468 <!DOCTYPE html><html> | 1491 <!DOCTYPE html><html> |
| 1469 <head> | 1492 <head> |
| 1493 <title>Driving page</title> | |
| 1470 <style> | 1494 <style> |
| 1471 body { | 1495 .big-notice { |
| 1472 margin: 0; | 1496 background-color: red; |
| 1473 } | 1497 color: white; |
| 1474 .box { | 1498 font-weight: bold; |
| 1475 overflow: hidden; | 1499 font-size: xx-large; |
| 1476 overflow-y: auto; | 1500 text-align: center; |
| 1477 position: absolute; | 1501 } |
| 1478 left: 0; | 1502 .controller.box { |
| 1479 right: 0; | 1503 white-space: nowrap; |
| 1480 } | 1504 overflow: scroll; |
| 1481 .controller.box { | 1505 height: 6em; |
| 1482 height: 75px; | 1506 } |
| 1483 top: 0; | 1507 body { |
| 1484 } | 1508 font-family: sans-serif; |
| 1485 .test.box { | 1509 } |
| 1486 top: 75px; | 1510 body div { |
| 1487 bottom: 0; | 1511 padding-top: 10px; |
| 1488 } | 1512 } |
| 1489 </style> | 1513 </style> |
| 1490 <title>Driving page</title> | |
| 1491 <script type='text/javascript'> | 1514 <script type='text/javascript'> |
| 1492 var STATUS_UPDATE_INTERVAL = 10000; | 1515 var STATUS_UPDATE_INTERVAL = 10000; |
| 1493 | 1516 |
| 1494 function startTesting() { | 1517 function startTesting() { |
| 1495 var number_of_tests = 0; | 1518 var number_of_tests = 0; |
| 1496 var current_id; | 1519 var current_id; |
| 1497 var next_id; | 1520 var next_id; |
| 1498 | 1521 |
| 1499 // Has the test in the current iframe reported that it is done? | 1522 // Has the test in the current iframe reported that it is done? |
| 1500 var test_completed = true; | 1523 var test_completed = true; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 if (use_iframe) { | 1633 if (use_iframe) { |
| 1611 if (html_test) { | 1634 if (html_test) { |
| 1612 window.addEventListener('detect_errors', setChildHandlers, false); | 1635 window.addEventListener('detect_errors', setChildHandlers, false); |
| 1613 embedded_iframe.onload = checkChildHandlersInstalled; | 1636 embedded_iframe.onload = checkChildHandlersInstalled; |
| 1614 } else { | 1637 } else { |
| 1615 embedded_iframe.onload = null; | 1638 embedded_iframe.onload = null; |
| 1616 } | 1639 } |
| 1617 embedded_iframe_div.removeChild(embedded_iframe); | 1640 embedded_iframe_div.removeChild(embedded_iframe); |
| 1618 embedded_iframe = document.createElement('iframe'); | 1641 embedded_iframe = document.createElement('iframe'); |
| 1619 embedded_iframe.id = "embedded_iframe"; | 1642 embedded_iframe.id = "embedded_iframe"; |
| 1620 embedded_iframe.style="width:100%;height:100%"; | 1643 embedded_iframe.width='800px'; |
| 1644 embedded_iframe.height='600px'; | |
| 1621 embedded_iframe_div.appendChild(embedded_iframe); | 1645 embedded_iframe_div.appendChild(embedded_iframe); |
| 1622 embedded_iframe.src = url; | 1646 embedded_iframe.src = url; |
| 1623 } else { | 1647 } else { |
| 1624 if (typeof testing_window != 'undefined') { | 1648 if (typeof testing_window != 'undefined') { |
| 1625 testing_window.close(); | 1649 testing_window.close(); |
| 1626 } | 1650 } |
| 1627 testing_window = window.open(url); | 1651 testing_window = window.open(url); |
| 1628 } | 1652 } |
| 1629 test_started = false; | 1653 test_started = false; |
| 1630 test_completed = false; | 1654 test_completed = false; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1782 | 1806 |
| 1783 if (!html_test) { | 1807 if (!html_test) { |
| 1784 window.addEventListener('message', messageHandler, false); | 1808 window.addEventListener('message', messageHandler, false); |
| 1785 waitForDone = false; | 1809 waitForDone = false; |
| 1786 } | 1810 } |
| 1787 getNextTask(); | 1811 getNextTask(); |
| 1788 } | 1812 } |
| 1789 </script> | 1813 </script> |
| 1790 </head> | 1814 </head> |
| 1791 <body onload="startTesting()"> | 1815 <body onload="startTesting()"> |
| 1816 | |
| 1817 <div class='big-notice'> | |
| 1818 Please keep this window in focus at all times. | |
| 1819 </div> | |
| 1820 | |
| 1821 <div> | |
| 1822 Some browsers, Safari, in particular, may pause JavaScript when not | |
| 1823 visible to conserve power consumption and CPU resources. In addition, | |
| 1824 some tests of focus events will not work correctly if this window doesn't | |
| 1825 have focus. It's also advisable to close any other programs that may open | |
| 1826 modal dialogs, for example, Chrome with Calendar open. | |
| 1827 </div> | |
| 1828 | |
| 1792 <div class="controller box"> | 1829 <div class="controller box"> |
| 1793 Dart test driver, number of tests: <span id="number"></span><br> | 1830 Dart test driver, number of tests: <span id="number"></span><br> |
| 1794 Currently executing: <span id="currently_executing"></span><br> | 1831 Currently executing: <span id="currently_executing"></span><br> |
| 1795 Unhandled error: <span id="unhandled_error"></span> | 1832 Unhandled error: <span id="unhandled_error"></span> |
| 1796 </div> | 1833 </div> |
| 1797 <div id="embedded_iframe_div" class="test box"> | 1834 <div id="embedded_iframe_div" class="test box"> |
| 1798 <iframe style="width:100%;height:100%;" id="embedded_iframe"></iframe> | 1835 <iframe id="embedded_iframe"></iframe> |
| 1799 </div> | 1836 </div> |
| 1800 </body> | 1837 </body> |
| 1801 </html> | 1838 </html> |
| 1802 """; | 1839 """; |
| 1803 return driverContent; | 1840 return driverContent; |
| 1804 } | 1841 } |
| 1805 } | 1842 } |
| OLD | NEW |