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

Unified Diff: lib/src/runner/browser/firefox.dart

Issue 1070313002: Add firefox support. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Don't double-compile test suites Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/runner/browser/chrome.dart ('k') | lib/src/runner/browser/server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/firefox.dart
diff --git a/lib/src/runner/browser/chrome.dart b/lib/src/runner/browser/firefox.dart
similarity index 68%
copy from lib/src/runner/browser/chrome.dart
copy to lib/src/runner/browser/firefox.dart
index c21ec8cfdbff127de66858f42a80b536fe5757df..dac103be8178eaaccd5bd3a031c8dd5fc94d4c18 100644
--- a/lib/src/runner/browser/chrome.dart
+++ b/lib/src/runner/browser/firefox.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library test.runner.browser.chrome;
+library test.runner.browser.firefox;
import 'dart:async';
import 'dart:io';
@@ -10,17 +10,22 @@ import 'dart:io';
import 'package:path/path.dart' as p;
import '../../util/io.dart';
+import 'browser.dart';
-// TODO(nweiz): move this into its own package?
-// TODO(nweiz): support other browsers.
-/// A class for running an instance of Chrome.
+final _preferences = '''
+user_pref("browser.shell.checkDefaultBrowser", false);
+user_pref("dom.disable_open_during_load", false);
+user_pref("dom.max_script_run_time", 0);
+''';
+
+/// A class for running an instance of Firefox.
///
/// Most of the communication with the browser is expected to happen via HTTP,
/// so this exposes a bare-bones API. The browser starts as soon as the class is
/// constructed, and is killed when [close] is called.
///
/// Any errors starting or running the process are reported through [onExit].
-class Chrome {
+class Firefox implements Browser {
/// The underlying process.
Process _process;
@@ -30,10 +35,6 @@ class Chrome {
/// well-isolated.
String _dir;
- /// A future that completes when the browser exits.
- ///
- /// If there's a problem starting or running the browser, this will complete
- /// with an error.
Future get onExit => _onExitCompleter.future;
final _onExitCompleter = new Completer();
@@ -43,12 +44,12 @@ class Chrome {
Future get _onProcessStarted => _onProcessStartedCompleter.future;
final _onProcessStartedCompleter = new Completer();
- /// Starts a new instance of Chrome open to the given [url], which may be a
+ /// Starts a new instance of Firefox open to the given [url], which may be a
/// [Uri] or a [String].
///
- /// If [executable] is passed, it's used as the Chrome executable. Otherwise
+ /// If [executable] is passed, it's used as the Firefox executable. Otherwise
/// the default executable name for the current OS will be used.
- Chrome(url, {String executable}) {
+ Firefox(url, {String executable}) {
if (executable == null) executable = _defaultExecutable();
// Don't return a Future here because there's no need for the caller to wait
@@ -56,16 +57,14 @@ class Chrome {
// request instead.
withTempDir((dir) {
_dir = dir;
+
+ new File(p.join(dir, 'prefs.js')).writeAsStringSync(_preferences);
+
return Process.start(executable, [
- "--user-data-dir=$_dir",
+ "--profile",
+ "$_dir",
url.toString(),
- "--disable-extensions",
- "--disable-popup-blocking",
- "--bwsi",
- "--no-first-run",
- "--no-default-browser-check",
- "--disable-default-apps",
- "--disable-translate"
+ "--no-remote"
]).then((process) {
_process = process;
_onProcessStartedCompleter.complete();
@@ -75,15 +74,11 @@ class Chrome {
return _process.exitCode;
});
}).then((exitCode) {
- if (exitCode != 0) throw "Chrome failed with exit code $exitCode.";
+ if (exitCode != 0) throw "Firefox failed with exit code $exitCode.";
}).then(_onExitCompleter.complete)
.catchError(_onExitCompleter.completeError);
}
- /// Kills the browser process.
- ///
- /// Returns the same [Future] as [onExit], except that it won't emit
- /// exceptions.
Future close() {
_onProcessStarted.then((_) => _process.kill());
@@ -94,18 +89,17 @@ class Chrome {
/// Return the default executable for the current operating system.
String _defaultExecutable() {
if (Platform.isMacOS) {
- return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
+ return '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
}
- if (!Platform.isWindows) return 'google-chrome';
+ if (!Platform.isWindows) return 'firefox';
- // Chrome could be installed in several places on Windows. The only way to
+ // Firefox could be installed in several places on Windows. The only way to
// find it is to check.
var prefixes = [
- Platform.environment['LOCALAPPDATA'],
Platform.environment['PROGRAMFILES'],
Platform.environment['PROGRAMFILES(X86)']
];
- var suffix = r'Google\Chrome\Application\chrome.exe';
+ var suffix = r'Mozilla Firefox\firefox.exe';
for (var prefix in prefixes) {
if (prefix == null) continue;
@@ -116,6 +110,6 @@ class Chrome {
// Fall back on looking it up on the path. This probably won't work, but at
// least it will fail with a useful error message.
- return "chrome.exe";
+ return "firefox.exe";
}
}
« no previous file with comments | « lib/src/runner/browser/chrome.dart ('k') | lib/src/runner/browser/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698