| Index: tools/testing/dart/browser_controller.dart
|
| diff --git a/tools/testing/dart/browser_controller.dart b/tools/testing/dart/browser_controller.dart
|
| index 2e5c1e736c06ed574a5cf43756042f6a2e21dc4e..6e375499bf2f37690c0ecd93ce40d79157f0fb99 100644
|
| --- a/tools/testing/dart/browser_controller.dart
|
| +++ b/tools/testing/dart/browser_controller.dart
|
| @@ -67,9 +67,8 @@ abstract class Browser {
|
|
|
| Browser();
|
|
|
| - factory Browser.byName(String name,
|
| - String executablePath,
|
| - [bool checkedMode = false]) {
|
| + factory Browser.byName(String name, String executablePath,
|
| + [bool checkedMode = false]) {
|
| var browser;
|
| if (name == 'firefox') {
|
| browser = new Firefox();
|
| @@ -90,12 +89,21 @@ abstract class Browser {
|
| return browser;
|
| }
|
|
|
| - static const List<String> SUPPORTED_BROWSERS =
|
| - const ['safari', 'ff', 'firefox', 'chrome', 'ie9', 'ie10',
|
| - 'ie11', 'dartium'];
|
| -
|
| - static const List<String> BROWSERS_WITH_WINDOW_SUPPORT =
|
| - const ['ie11', 'ie10'];
|
| + static const List<String> SUPPORTED_BROWSERS = const [
|
| + 'safari',
|
| + 'ff',
|
| + 'firefox',
|
| + 'chrome',
|
| + 'ie9',
|
| + 'ie10',
|
| + 'ie11',
|
| + 'dartium'
|
| + ];
|
| +
|
| + static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = const [
|
| + 'ie11',
|
| + 'ie10'
|
| + ];
|
|
|
| // TODO(kustermann): add standard support for chrome on android
|
| static bool supportedBrowser(String name) {
|
| @@ -144,10 +152,10 @@ abstract class Browser {
|
| * Start the browser using the supplied argument.
|
| * This sets up the error handling and usage logging.
|
| */
|
| - Future<bool> startBrowserProcess(String command,
|
| - List<String> arguments,
|
| - {Map<String,String> environment}) {
|
| - return Process.start(command, arguments, environment: environment)
|
| + Future<bool> startBrowserProcess(String command, List<String> arguments,
|
| + {Map<String, String> environment}) {
|
| + return Process
|
| + .start(command, arguments, environment: environment)
|
| .then((startedProcess) {
|
| _logEvent("Started browser using $command ${arguments.join(' ')}");
|
| process = startedProcess;
|
| @@ -169,7 +177,7 @@ abstract class Browser {
|
| // handles alive even though the direct subprocess is dead.
|
| Timer watchdogTimer;
|
|
|
| - void closeStdout([_]){
|
| + void closeStdout([_]) {
|
| if (!stdoutIsDone) {
|
| stdoutDone.complete();
|
| stdoutIsDone = true;
|
| @@ -192,7 +200,7 @@ abstract class Browser {
|
| }
|
|
|
| stdoutSubscription =
|
| - process.stdout.transform(UTF8.decoder).listen((data) {
|
| + process.stdout.transform(UTF8.decoder).listen((data) {
|
| _addStdout(data);
|
| }, onError: (error) {
|
| // This should _never_ happen, but we really want this in the log
|
| @@ -201,21 +209,21 @@ abstract class Browser {
|
| }, onDone: closeStdout);
|
|
|
| stderrSubscription =
|
| - process.stderr.transform(UTF8.decoder).listen((data) {
|
| + process.stderr.transform(UTF8.decoder).listen((data) {
|
| _addStderr(data);
|
| }, onError: (error) {
|
| // This should _never_ happen, but we really want this in the log
|
| // if it actually does due to dart:io or vm bug.
|
| _logEvent("An error occured in the process stderr handling: $error");
|
| - }, onDone: closeStderr);
|
| + }, onDone: closeStderr);
|
|
|
| process.exitCode.then((exitCode) {
|
| _logEvent("Browser closed with exitcode $exitCode");
|
|
|
| if (!stdoutIsDone || !stderrIsDone) {
|
| watchdogTimer = new Timer(MAX_STDIO_DELAY, () {
|
| - DebugLogger.warning(
|
| - "$MAX_STDIO_DELAY_PASSED_MESSAGE (browser: $this)");
|
| + DebugLogger
|
| + .warning("$MAX_STDIO_DELAY_PASSED_MESSAGE (browser: $this)");
|
| watchdogTimer = null;
|
| stdoutSubscription.cancel();
|
| stderrSubscription.cancel();
|
| @@ -255,7 +263,7 @@ abstract class Browser {
|
| * where it will be reported for failing tests. Used to report which
|
| * android device a failing test is running on.
|
| */
|
| - void logBrowserInfoToTestBrowserOutput() { }
|
| + void logBrowserInfoToTestBrowserOutput() {}
|
|
|
| String toString();
|
|
|
| @@ -274,19 +282,22 @@ class Safari extends Browser {
|
| * Directories where safari stores state. We delete these if the deleteCache
|
| * is set
|
| */
|
| - static const List<String> CACHE_DIRECTORIES =
|
| - const ["Library/Caches/com.apple.Safari",
|
| - "Library/Safari",
|
| - "Library/Saved Application State/com.apple.Safari.savedState",
|
| - "Library/Caches/Metadata/Safari"];
|
| -
|
| + static const List<String> CACHE_DIRECTORIES = const [
|
| + "Library/Caches/com.apple.Safari",
|
| + "Library/Safari",
|
| + "Library/Saved Application State/com.apple.Safari.savedState",
|
| + "Library/Caches/Metadata/Safari"
|
| + ];
|
|
|
| Future<bool> allowPopUps() {
|
| var command = "defaults";
|
| - var args = ["write", "com.apple.safari",
|
| - "com.apple.Safari.ContentPageGroupIdentifier."
|
| - "WebKit2JavaScriptCanOpenWindowsAutomatically",
|
| - "1"];
|
| + var args = [
|
| + "write",
|
| + "com.apple.safari",
|
| + "com.apple.Safari.ContentPageGroupIdentifier."
|
| + "WebKit2JavaScriptCanOpenWindowsAutomatically",
|
| + "1"
|
| + ];
|
| return Process.run(command, args).then((result) {
|
| if (result.exitCode != 0) {
|
| _logEvent("Could not disable pop-up blocking for safari");
|
| @@ -302,12 +313,13 @@ class Safari extends Browser {
|
| return directory.exists().then((exists) {
|
| if (exists) {
|
| _logEvent("Deleting ${paths.current}");
|
| - return directory.delete(recursive: true)
|
| - .then((_) => deleteIfExists(paths))
|
| - .catchError((error) {
|
| - _logEvent("Failure trying to delete ${paths.current}: $error");
|
| - return false;
|
| - });
|
| + return directory
|
| + .delete(recursive: true)
|
| + .then((_) => deleteIfExists(paths))
|
| + .catchError((error) {
|
| + _logEvent("Failure trying to delete ${paths.current}: $error");
|
| + return false;
|
| + });
|
| } else {
|
| _logEvent("${paths.current} is not present");
|
| return deleteIfExists(paths);
|
| @@ -380,7 +392,9 @@ class Safari extends Browser {
|
| return getVersion().then((version) {
|
| _logEvent("Got version: $version");
|
| return Directory.systemTemp.createTemp().then((userDir) {
|
| - _cleanup = () { userDir.deleteSync(recursive: true); };
|
| + _cleanup = () {
|
| + userDir.deleteSync(recursive: true);
|
| + };
|
| _createLaunchHTML(userDir.path, url);
|
| var args = ["${userDir.path}/launch.html"];
|
| return startBrowserProcess(_binary, args);
|
| @@ -396,7 +410,6 @@ class Safari extends Browser {
|
| String toString() => "Safari";
|
| }
|
|
|
| -
|
| class Chrome extends Browser {
|
| String _version = "Version not found yet";
|
|
|
| @@ -430,7 +443,6 @@ class Chrome extends Browser {
|
| });
|
| }
|
|
|
| -
|
| Future<bool> start(String url) {
|
| _logEvent("Starting chrome browser on: $url");
|
| // Get the version and log that.
|
| @@ -439,11 +451,19 @@ class Chrome extends Browser {
|
| _logEvent("Got version: $_version");
|
|
|
| return Directory.systemTemp.createTemp().then((userDir) {
|
| - _cleanup = () { userDir.deleteSync(recursive: true); };
|
| - var args = ["--user-data-dir=${userDir.path}", url,
|
| - "--disable-extensions", "--disable-popup-blocking",
|
| - "--bwsi", "--no-first-run"];
|
| - return startBrowserProcess(_binary, args, environment: _getEnvironment());
|
| + _cleanup = () {
|
| + userDir.deleteSync(recursive: true);
|
| + };
|
| + var args = [
|
| + "--user-data-dir=${userDir.path}",
|
| + url,
|
| + "--disable-extensions",
|
| + "--disable-popup-blocking",
|
| + "--bwsi",
|
| + "--no-first-run"
|
| + ];
|
| + return startBrowserProcess(_binary, args,
|
| + environment: _getEnvironment());
|
| });
|
| }).catchError((e) {
|
| _logEvent("Running $_binary --version failed with $e");
|
| @@ -454,14 +474,14 @@ class Chrome extends Browser {
|
| String toString() => "Chrome";
|
| }
|
|
|
| -
|
| class SafariMobileSimulator extends Safari {
|
| /**
|
| * Directories where safari simulator stores state. We delete these if the
|
| * deleteCache is set
|
| */
|
| - static const List<String> CACHE_DIRECTORIES =
|
| - const ["Library/Application Support/iPhone Simulator/7.1/Applications"];
|
| + static const List<String> CACHE_DIRECTORIES = const [
|
| + "Library/Application Support/iPhone Simulator/7.1/Applications"
|
| + ];
|
|
|
| // Clears the cache if the static deleteCache flag is set.
|
| // Returns false if the command to actually clear the cache did not complete.
|
| @@ -477,33 +497,34 @@ class SafariMobileSimulator extends Safari {
|
| return clearCache().then((success) {
|
| if (!success) {
|
| _logEvent("Could not clear cache, exiting");
|
| - return false;
|
| + return false;
|
| }
|
| - var args = ["-SimulateApplication",
|
| - "/Applications/Xcode.app/Contents/Developer/Platforms/"
|
| - "iPhoneSimulator.platform/Developer/SDKs/"
|
| - "iPhoneSimulator7.1.sdk/Applications/MobileSafari.app/"
|
| - "MobileSafari",
|
| - "-u", url];
|
| - return startBrowserProcess(_binary, args)
|
| - .catchError((e) {
|
| - _logEvent("Running $_binary --version failed with $e");
|
| - return false;
|
| - });
|
| + var args = [
|
| + "-SimulateApplication",
|
| + "/Applications/Xcode.app/Contents/Developer/Platforms/"
|
| + "iPhoneSimulator.platform/Developer/SDKs/"
|
| + "iPhoneSimulator7.1.sdk/Applications/MobileSafari.app/"
|
| + "MobileSafari",
|
| + "-u",
|
| + url
|
| + ];
|
| + return startBrowserProcess(_binary, args).catchError((e) {
|
| + _logEvent("Running $_binary --version failed with $e");
|
| + return false;
|
| + });
|
| });
|
| }
|
|
|
| String toString() => "SafariMobileSimulator";
|
| }
|
|
|
| -
|
| class Dartium extends Chrome {
|
| final bool checkedMode;
|
|
|
| Dartium(this.checkedMode);
|
|
|
| Map<String, String> _getEnvironment() {
|
| - var environment = new Map<String,String>.from(Platform.environment);
|
| + var environment = new Map<String, String>.from(Platform.environment);
|
| // By setting this environment variable, dartium will forward "print()"
|
| // calls in dart to the top-level javascript function "dartPrint()" if
|
| // available.
|
| @@ -519,10 +540,12 @@ class Dartium extends Chrome {
|
|
|
| class IE extends Browser {
|
| Future<String> getVersion() {
|
| - var args = ["query",
|
| - "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer",
|
| - "/v",
|
| - "svcVersion"];
|
| + var args = [
|
| + "query",
|
| + "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer",
|
| + "/v",
|
| + "svcVersion"
|
| + ];
|
| return Process.run("reg", args).then((result) {
|
| if (result.exitCode == 0) {
|
| // The string we get back looks like this:
|
| @@ -544,13 +567,13 @@ class IE extends Browser {
|
| var localAppData = Platform.environment['LOCALAPPDATA'];
|
|
|
| Directory dir = new Directory("$localAppData\\Microsoft\\"
|
| - "Internet Explorer\\Recovery");
|
| - return dir.delete(recursive: true)
|
| - .then((_) { return true; })
|
| - .catchError((error) {
|
| - _logEvent("Deleting recovery dir failed with $error");
|
| - return false;
|
| - });
|
| + "Internet Explorer\\Recovery");
|
| + return dir.delete(recursive: true).then((_) {
|
| + return true;
|
| + }).catchError((error) {
|
| + _logEvent("Deleting recovery dir failed with $error");
|
| + return false;
|
| + });
|
| }
|
|
|
| Future<bool> start(String url) {
|
| @@ -560,11 +583,10 @@ class IE extends Browser {
|
| return startBrowserProcess(_binary, [url]);
|
| });
|
| }
|
| - String toString() => "IE";
|
|
|
| + String toString() => "IE";
|
| }
|
|
|
| -
|
| class AndroidBrowserConfig {
|
| final String name;
|
| final String package;
|
| @@ -573,20 +595,14 @@ class AndroidBrowserConfig {
|
| AndroidBrowserConfig(this.name, this.package, this.activity, this.action);
|
| }
|
|
|
| -
|
| final contentShellOnAndroidConfig = new AndroidBrowserConfig(
|
| 'ContentShellOnAndroid',
|
| 'org.chromium.content_shell_apk',
|
| '.ContentShellActivity',
|
| 'android.intent.action.VIEW');
|
|
|
| -
|
| -final dartiumOnAndroidConfig = new AndroidBrowserConfig(
|
| - 'DartiumOnAndroid',
|
| - 'com.google.android.apps.chrome',
|
| - '.Main',
|
| - 'android.intent.action.VIEW');
|
| -
|
| +final dartiumOnAndroidConfig = new AndroidBrowserConfig('DartiumOnAndroid',
|
| + 'com.google.android.apps.chrome', '.Main', 'android.intent.action.VIEW');
|
|
|
| class AndroidBrowser extends Browser {
|
| final bool checkedMode;
|
| @@ -598,8 +614,8 @@ class AndroidBrowser extends Browser {
|
| }
|
|
|
| Future<bool> start(String url) {
|
| - var intent = new Intent(
|
| - _config.action, _config.package, _config.activity, url);
|
| + var intent =
|
| + new Intent(_config.action, _config.package, _config.activity, url);
|
| return _adbDevice.waitForBootCompleted().then((_) {
|
| return _adbDevice.forceStop(_config.package);
|
| }).then((_) {
|
| @@ -631,14 +647,13 @@ class AndroidBrowser extends Browser {
|
| }
|
|
|
| void logBrowserInfoToTestBrowserOutput() {
|
| - _testBrowserOutput.stdout.write(
|
| - 'Android device id: ${_adbDevice.deviceId}\n');
|
| + _testBrowserOutput.stdout
|
| + .write('Android device id: ${_adbDevice.deviceId}\n');
|
| }
|
|
|
| String toString() => _config.name;
|
| }
|
|
|
| -
|
| class AndroidChrome extends Browser {
|
| static const String viewAction = 'android.intent.action.VIEW';
|
| static const String mainAction = 'android.intent.action.MAIN';
|
| @@ -652,8 +667,8 @@ class AndroidChrome extends Browser {
|
| AndroidChrome(this._adbDevice);
|
|
|
| Future<bool> start(String url) {
|
| - var browserIntent = new Intent(
|
| - viewAction, browserPackage, '.BrowserActivity', url);
|
| + var browserIntent =
|
| + new Intent(viewAction, browserPackage, '.BrowserActivity', url);
|
| var chromeIntent = new Intent(viewAction, chromePackage, '.Main', url);
|
| var firefoxIntent = new Intent(viewAction, firefoxPackage, '.App', url);
|
| var turnScreenOnIntent =
|
| @@ -702,14 +717,13 @@ class AndroidChrome extends Browser {
|
| }
|
|
|
| void logBrowserInfoToTestBrowserOutput() {
|
| - _testBrowserOutput.stdout.write(
|
| - 'Android device id: ${_adbDevice.deviceId}\n');
|
| + _testBrowserOutput.stdout
|
| + .write('Android device id: ${_adbDevice.deviceId}\n');
|
| }
|
|
|
| String toString() => "chromeOnAndroid";
|
| }
|
|
|
| -
|
| class Firefox extends Browser {
|
| static const String enablePopUp =
|
| 'user_pref("dom.disable_open_during_load", false);';
|
| @@ -741,13 +755,19 @@ class Firefox extends Browser {
|
|
|
| return Directory.systemTemp.createTemp().then((userDir) {
|
| _createPreferenceFile(userDir.path);
|
| - _cleanup = () { userDir.deleteSync(recursive: true); };
|
| - var args = ["-profile", "${userDir.path}",
|
| - "-no-remote", "-new-instance", url];
|
| - var environment = new Map<String,String>.from(Platform.environment);
|
| + _cleanup = () {
|
| + userDir.deleteSync(recursive: true);
|
| + };
|
| + var args = [
|
| + "-profile",
|
| + "${userDir.path}",
|
| + "-no-remote",
|
| + "-new-instance",
|
| + url
|
| + ];
|
| + var environment = new Map<String, String>.from(Platform.environment);
|
| environment["MOZ_CRASHREPORTER_DISABLE"] = "1";
|
| return startBrowserProcess(_binary, args, environment: environment);
|
| -
|
| });
|
| }).catchError((e) {
|
| _logEvent("Running $_binary --version failed with $e");
|
| @@ -758,7 +778,6 @@ class Firefox extends Browser {
|
| String toString() => "Firefox";
|
| }
|
|
|
| -
|
| /**
|
| * Describes the current state of a browser used for testing.
|
| */
|
| @@ -777,7 +796,6 @@ class BrowserStatus {
|
| BrowserStatus(Browser this.browser);
|
| }
|
|
|
| -
|
| /**
|
| * Describes a single test to be run in the browser.
|
| */
|
| @@ -805,12 +823,9 @@ class BrowserTest {
|
| id = _idCounter++;
|
| }
|
|
|
| - String toJSON() => JSON.encode({'url': url,
|
| - 'id': id,
|
| - 'isHtmlTest': false});
|
| + String toJSON() => JSON.encode({'url': url, 'id': id, 'isHtmlTest': false});
|
| }
|
|
|
| -
|
| /**
|
| * Describes a test with a custom HTML page to be run in the browser.
|
| */
|
| @@ -818,15 +833,16 @@ class HtmlTest extends BrowserTest {
|
| List<String> expectedMessages;
|
|
|
| HtmlTest(url, doneCallback, timeout, this.expectedMessages)
|
| - : super(url, doneCallback, timeout) { }
|
| + : super(url, doneCallback, timeout) {}
|
|
|
| - String toJSON() => JSON.encode({'url': url,
|
| - 'id': id,
|
| - 'isHtmlTest': true,
|
| - 'expectedMessages': expectedMessages});
|
| + String toJSON() => JSON.encode({
|
| + 'url': url,
|
| + 'id': id,
|
| + 'isHtmlTest': true,
|
| + 'expectedMessages': expectedMessages
|
| + });
|
| }
|
|
|
| -
|
| /* Describes the output of running the test in a browser */
|
| class BrowserTestOutput {
|
| final Duration delayUntilTestStarted;
|
| @@ -837,12 +853,11 @@ class BrowserTestOutput {
|
| final BrowserOutput browserOutput;
|
| final bool didTimeout;
|
|
|
| - BrowserTestOutput(
|
| - this.delayUntilTestStarted, this.duration, this.lastKnownMessage,
|
| - this.browserOutput, {this.didTimeout: false});
|
| + BrowserTestOutput(this.delayUntilTestStarted, this.duration,
|
| + this.lastKnownMessage, this.browserOutput,
|
| + {this.didTimeout: false});
|
| }
|
|
|
| -
|
| /// Encapsulates all the functionality for running tests in browsers.
|
| /// Tests are added to the queue and the supplied callbacks are called
|
| /// when a test completes.
|
| @@ -879,8 +894,7 @@ class BrowserTestRunner {
|
| DateTime lastEmptyTestQueueTime = new DateTime.now();
|
| String _currentStartingBrowserId;
|
| List<BrowserTest> testQueue = new List<BrowserTest>();
|
| - Map<String, BrowserStatus> browserStatus =
|
| - new Map<String, BrowserStatus>();
|
| + Map<String, BrowserStatus> browserStatus = new Map<String, BrowserStatus>();
|
|
|
| var adbDeviceMapping = new Map<String, AdbDevice>();
|
| List<AdbDevice> idleAdbDevices;
|
| @@ -907,8 +921,9 @@ class BrowserTestRunner {
|
| // When no browser is currently starting, _currentStartingBrowserId is null.
|
| bool get aBrowserIsCurrentlyStarting => _currentStartingBrowserId != null;
|
| void markCurrentlyStarting(String id) {
|
| - _currentStartingBrowserId = id;
|
| + _currentStartingBrowserId = id;
|
| }
|
| +
|
| void markNotCurrentlyStarting(String id) {
|
| if (_currentStartingBrowserId == id) _currentStartingBrowserId = null;
|
| }
|
| @@ -916,32 +931,30 @@ class BrowserTestRunner {
|
| // If [browserName] doesn't support opening new windows, we use new iframes
|
| // instead.
|
| bool get useIframe =>
|
| - !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName);
|
| + !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName);
|
|
|
| /// The optional testingServer parameter allows callers to pass in
|
| /// a testing server with different behavior than the default
|
| /// BrowserTestServer. The url handlers of the testingServer are
|
| /// overwritten, so an existing handler can't be shared between instances.
|
| - BrowserTestRunner(this.configuration,
|
| - this.localIp,
|
| - this.browserName,
|
| - this.maxNumBrowsers,
|
| - {BrowserTestingServer this.testingServer}) {
|
| + BrowserTestRunner(
|
| + this.configuration, this.localIp, this.browserName, this.maxNumBrowsers,
|
| + {BrowserTestingServer this.testingServer}) {
|
| checkedMode = configuration['checked'];
|
| if (browserName == 'ff') browserName = 'firefox';
|
| }
|
|
|
| Future start() async {
|
| if (testingServer == null) {
|
| - testingServer = new BrowserTestingServer(
|
| - configuration, localIp, useIframe);
|
| + testingServer =
|
| + new BrowserTestingServer(configuration, localIp, useIframe);
|
| }
|
| await testingServer.start();
|
| testingServer
|
| - ..testDoneCallBack = handleResults
|
| - ..testStatusUpdateCallBack = handleStatusUpdate
|
| - ..testStartedCallBack = handleStarted
|
| - ..nextTestCallBack = getNextTest;
|
| + ..testDoneCallBack = handleResults
|
| + ..testStatusUpdateCallBack = handleStatusUpdate
|
| + ..testStartedCallBack = handleStarted
|
| + ..nextTestCallBack = getNextTest;
|
| if (browserName == 'chromeOnAndroid') {
|
| var idbNames = await AdbHelper.listDevices();
|
| idleAdbDevices = new List.from(idbNames.map((id) => new AdbDevice(id)));
|
| @@ -974,7 +987,7 @@ class BrowserTestRunner {
|
| final String url = testingServer.getDriverUrl(id);
|
| Browser browser;
|
| if (browserName == 'chromeOnAndroid') {
|
| - AdbDevice device = idleAdbDevices.removeLast();
|
| + AdbDevice device = idleAdbDevices.removeLast();
|
| adbDeviceMapping[id] = device;
|
| browser = new AndroidChrome(device);
|
| } else {
|
| @@ -1008,11 +1021,11 @@ class BrowserTestRunner {
|
|
|
| if (status.currentTest.id != testId) {
|
| print("Expected test id ${status.currentTest.id} for"
|
| - "${status.currentTest.url}");
|
| + "${status.currentTest.url}");
|
| print("Got test id ${testId}");
|
| print("Last test id was ${status.lastTest.id} for "
|
| - "${status.currentTest.url}");
|
| - throw("This should never happen, wrong test id");
|
| + "${status.currentTest.url}");
|
| + throw ("This should never happen, wrong test id");
|
| }
|
| testCache[testId] = status.currentTest.url;
|
|
|
| @@ -1065,8 +1078,7 @@ class BrowserTestRunner {
|
| // We simply kill the browser and starts up a new one!
|
| // We could be smarter here, but it does not seems like it is worth it.
|
| if (status.timeout) {
|
| - DebugLogger.error(
|
| - "Got test timeout for an already restarting browser");
|
| + DebugLogger.error("Got test timeout for an already restarting browser");
|
| return;
|
| }
|
| status.timeout = true;
|
| @@ -1127,8 +1139,7 @@ class BrowserTestRunner {
|
| // Restart Internet Explorer if it has been
|
| // running for longer than RESTART_BROWSER_INTERVAL. The tests have
|
| // had flaky timeouts, and this may help.
|
| - if ((browserName == 'ie10' ||
|
| - browserName == 'ie11') &&
|
| + if ((browserName == 'ie10' || browserName == 'ie11') &&
|
| status.timeSinceRestart.elapsed > RESTART_BROWSER_INTERVAL) {
|
| var id = status.browser.id;
|
| // Reset stopwatch so we don't trigger again before restarting.
|
| @@ -1178,20 +1189,22 @@ class BrowserTestRunner {
|
|
|
| /// Creates a timer that is active while a test is running on a browser.
|
| Timer createTimeoutTimer(BrowserTest test, BrowserStatus status) {
|
| - return new Timer(new Duration(seconds: test.timeout),
|
| - () { handleTimeout(status); });
|
| + return new Timer(new Duration(seconds: test.timeout), () {
|
| + handleTimeout(status);
|
| + });
|
| }
|
|
|
| /// Creates a timer that is active while no test is running on the
|
| /// browser. It has finished one test, and it has not requested a new test.
|
| Timer createNextTestTimer(BrowserStatus status) {
|
| - return new Timer(BrowserTestRunner.NEXT_TEST_TIMEOUT,
|
| - () { handleNextTestTimeout(status); });
|
| + return new Timer(BrowserTestRunner.NEXT_TEST_TIMEOUT, () {
|
| + handleNextTestTimeout(status);
|
| + });
|
| }
|
|
|
| void handleNextTestTimeout(status) {
|
| - DebugLogger.warning(
|
| - "Browser timed out before getting next test. Restarting");
|
| + DebugLogger
|
| + .warning("Browser timed out before getting next test. Restarting");
|
| if (status.timeout) return;
|
| numBrowserGetTestTimeouts++;
|
| if (numBrowserGetTestTimeouts >= MAX_NEXT_TEST_TIMEOUTS) {
|
| @@ -1255,6 +1268,7 @@ class BrowserTestRunner {
|
|
|
| class BrowserTestingServer {
|
| final Map configuration;
|
| +
|
| /// Interface of the testing server:
|
| ///
|
| /// GET /driver/BROWSER_ID -- This will get the driver page to fetch
|
| @@ -1291,9 +1305,10 @@ class BrowserTestingServer {
|
|
|
| Future start() {
|
| var test_driver_error_port = configuration['test_driver_error_port'];
|
| - return HttpServer.bind(localIp, test_driver_error_port)
|
| - .then(setupErrorServer)
|
| - .then(setupDispatchingServer);
|
| + return HttpServer
|
| + .bind(localIp, test_driver_error_port)
|
| + .then(setupErrorServer)
|
| + .then(setupDispatchingServer);
|
| }
|
|
|
| void setupErrorServer(HttpServer server) {
|
| @@ -1301,18 +1316,20 @@ class BrowserTestingServer {
|
| void errorReportingHandler(HttpRequest request) {
|
| StringBuffer buffer = new StringBuffer();
|
| request.transform(UTF8.decoder).listen((data) {
|
| - buffer.write(data);
|
| - }, onDone: () {
|
| - String back = buffer.toString();
|
| - request.response.headers.set("Access-Control-Allow-Origin", "*");
|
| - request.response.done.catchError((error) {
|
| - DebugLogger.error("Error getting error from browser"
|
| - "on uri ${request.uri.path}: $error");
|
| - });
|
| - request.response.close();
|
| - DebugLogger.error("Error from browser on : "
|
| - "${request.uri.path}, data: $back");
|
| - }, onError: (error) { print(error); });
|
| + buffer.write(data);
|
| + }, onDone: () {
|
| + String back = buffer.toString();
|
| + request.response.headers.set("Access-Control-Allow-Origin", "*");
|
| + request.response.done.catchError((error) {
|
| + DebugLogger.error("Error getting error from browser"
|
| + "on uri ${request.uri.path}: $error");
|
| + });
|
| + request.response.close();
|
| + DebugLogger.error("Error from browser on : "
|
| + "${request.uri.path}, data: $back");
|
| + }, onError: (error) {
|
| + print(error);
|
| + });
|
| }
|
| void errorHandler(e) {
|
| if (!underTermination) print("Error occured in httpserver: $e");
|
| @@ -1323,58 +1340,56 @@ class BrowserTestingServer {
|
| void setupDispatchingServer(_) {
|
| DispatchingServer server = configuration['_servers_'].server;
|
| void noCache(request) {
|
| - request.response.headers.set("Cache-Control",
|
| - "no-cache, no-store, must-revalidate");
|
| + request.response.headers
|
| + .set("Cache-Control", "no-cache, no-store, must-revalidate");
|
| }
|
| - int testId(request) =>
|
| - int.parse(request.uri.queryParameters["id"]);
|
| + int testId(request) => int.parse(request.uri.queryParameters["id"]);
|
| String browserId(request, prefix) =>
|
| request.uri.path.substring(prefix.length + 1);
|
|
|
| -
|
| server.addHandler(reportPath, (HttpRequest request) {
|
| noCache(request);
|
| - handleReport(request, browserId(request, reportPath),
|
| - testId(request), isStatusUpdate: false);
|
| + handleReport(request, browserId(request, reportPath), testId(request),
|
| + isStatusUpdate: false);
|
| });
|
| server.addHandler(statusUpdatePath, (HttpRequest request) {
|
| noCache(request);
|
| - handleReport(request, browserId(request, statusUpdatePath),
|
| - testId(request), isStatusUpdate: true);
|
| + handleReport(
|
| + request, browserId(request, statusUpdatePath), testId(request),
|
| + isStatusUpdate: true);
|
| });
|
| server.addHandler(startedPath, (HttpRequest request) {
|
| noCache(request);
|
| - handleStarted(request, browserId(request, startedPath),
|
| - testId(request));
|
| + handleStarted(request, browserId(request, startedPath), testId(request));
|
| });
|
|
|
| makeSendPageHandler(String prefix) => (HttpRequest request) {
|
| - noCache(request);
|
| - var textResponse = "";
|
| - if (prefix == driverPath) {
|
| - textResponse = getDriverPage(browserId(request, prefix));
|
| - request.response.headers.set('Content-Type', 'text/html');
|
| - }
|
| - if (prefix == nextTestPath) {
|
| - textResponse = getNextTest(browserId(request, prefix));
|
| - request.response.headers.set('Content-Type', 'text/plain');
|
| - }
|
| - request.response.write(textResponse);
|
| - request.listen((_) {}, onDone: request.response.close);
|
| - request.response.done.catchError((error) {
|
| - if (!underTermination) {
|
| - print("URI ${request.uri}");
|
| - print("Textresponse $textResponse");
|
| - throw "Error returning content to browser: $error";
|
| - }
|
| - });
|
| - };
|
| + noCache(request);
|
| + var textResponse = "";
|
| + if (prefix == driverPath) {
|
| + textResponse = getDriverPage(browserId(request, prefix));
|
| + request.response.headers.set('Content-Type', 'text/html');
|
| + }
|
| + if (prefix == nextTestPath) {
|
| + textResponse = getNextTest(browserId(request, prefix));
|
| + request.response.headers.set('Content-Type', 'text/plain');
|
| + }
|
| + request.response.write(textResponse);
|
| + request.listen((_) {}, onDone: request.response.close);
|
| + request.response.done.catchError((error) {
|
| + if (!underTermination) {
|
| + print("URI ${request.uri}");
|
| + print("Textresponse $textResponse");
|
| + throw "Error returning content to browser: $error";
|
| + }
|
| + });
|
| + };
|
| server.addHandler(driverPath, makeSendPageHandler(driverPath));
|
| server.addHandler(nextTestPath, makeSendPageHandler(nextTestPath));
|
| }
|
|
|
| void handleReport(HttpRequest request, String browserId, var testId,
|
| - {bool isStatusUpdate}) {
|
| + {bool isStatusUpdate}) {
|
| StringBuffer buffer = new StringBuffer();
|
| request.transform(UTF8.decoder).listen((data) {
|
| buffer.write(data);
|
| @@ -1387,7 +1402,9 @@ class BrowserTestingServer {
|
| testDoneCallBack(browserId, back, testId);
|
| }
|
| // TODO(ricow): We should do something smart if we get an error here.
|
| - }, onError: (error) { DebugLogger.error("$error"); });
|
| + }, onError: (error) {
|
| + DebugLogger.error("$error");
|
| + });
|
| }
|
|
|
| void handleStarted(HttpRequest request, String browserId, var testId) {
|
| @@ -1401,7 +1418,9 @@ class BrowserTestingServer {
|
| String back = buffer.toString();
|
| request.response.close();
|
| testStartedCallBack(browserId, back, testId);
|
| - }, onError: (error) { DebugLogger.error("$error"); });
|
| + }, onError: (error) {
|
| + DebugLogger.error("$error");
|
| + });
|
| }
|
|
|
| String getNextTest(String browserId) {
|
| @@ -1417,7 +1436,7 @@ class BrowserTestingServer {
|
| String getDriverUrl(String browserId) {
|
| if (errorReportingServer == null) {
|
| print("Bad browser testing server, you are not started yet. Can't "
|
| - "produce driver url");
|
| + "produce driver url");
|
| exit(1);
|
| // This should never happen - exit immediately;
|
| }
|
| @@ -1425,7 +1444,6 @@ class BrowserTestingServer {
|
| return "http://$localIp:$port/driver/$browserId";
|
| }
|
|
|
| -
|
| String getDriverPage(String browserId) {
|
| var errorReportingUrl =
|
| "http://$localIp:${errorReportingServer.port}/$browserId";
|
|
|