|
@@ -1,18 +1,19 @@
|
|
|
package Selenium::Firefox::Binary;
|
|
package Selenium::Firefox::Binary;
|
|
|
|
|
|
|
|
-# ABSTRACT: Portable handler to start the firefox binary
|
|
|
|
|
|
|
+# ABSTRACT: Subroutines for locating and properly initializing the Firefox Binary
|
|
|
use File::Which qw/which/;
|
|
use File::Which qw/which/;
|
|
|
|
|
+use Selenium::Firefox::Profile;
|
|
|
|
|
|
|
|
require Exporter;
|
|
require Exporter;
|
|
|
our @ISA = qw/Exporter/;
|
|
our @ISA = qw/Exporter/;
|
|
|
-our @EXPORT_OK = qw/firefox_path/;
|
|
|
|
|
|
|
+our @EXPORT_OK = qw/firefox_path setup_firefox_binary_env/;
|
|
|
|
|
|
|
|
-sub _windows_path {
|
|
|
|
|
|
|
+sub _firefox_windows_path {
|
|
|
# TODO: make this slightly less dumb
|
|
# TODO: make this slightly less dumb
|
|
|
return which('firefox');
|
|
return which('firefox');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-sub _darwin_path {
|
|
|
|
|
|
|
+sub _firefox_darwin_path {
|
|
|
my $default_firefox = '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
|
|
my $default_firefox = '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
|
|
|
|
|
|
|
|
if (-e $default_firefox) {
|
|
if (-e $default_firefox) {
|
|
@@ -23,7 +24,7 @@ sub _darwin_path {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-sub _unix_path {
|
|
|
|
|
|
|
+sub _firefox_unix_path {
|
|
|
# TODO: maybe which('firefox3'), which('firefox2') ?
|
|
# TODO: maybe which('firefox3'), which('firefox2') ?
|
|
|
return which('firefox') || '/usr/bin/firefox';
|
|
return which('firefox') || '/usr/bin/firefox';
|
|
|
}
|
|
}
|
|
@@ -31,13 +32,13 @@ sub _unix_path {
|
|
|
sub firefox_path {
|
|
sub firefox_path {
|
|
|
my $path;
|
|
my $path;
|
|
|
if ($^O eq 'MSWin32') {
|
|
if ($^O eq 'MSWin32') {
|
|
|
- $path =_windows_path();
|
|
|
|
|
|
|
+ $path =_firefox_windows_path();
|
|
|
}
|
|
}
|
|
|
elsif ($^O eq 'darwin') {
|
|
elsif ($^O eq 'darwin') {
|
|
|
- $path =_darwin_path();
|
|
|
|
|
|
|
+ $path = _firefox_darwin_path();
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- $path = _unix_path;
|
|
|
|
|
|
|
+ $path = _firefox_unix_path;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (not -x $path) {
|
|
if (not -x $path) {
|
|
@@ -47,4 +48,18 @@ sub firefox_path {
|
|
|
return $path;
|
|
return $path;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+sub setup_firefox_binary_env {
|
|
|
|
|
+ my ($port) = @_;
|
|
|
|
|
+
|
|
|
|
|
+ # TODO: respect the user's profile instead of overwriting it
|
|
|
|
|
+ my $profile = Selenium::Firefox::Profile->new;
|
|
|
|
|
+ $profile->add_webdriver($port);
|
|
|
|
|
+
|
|
|
|
|
+ $ENV{'XRE_PROFILE_PATH'} = $profile->_layout_on_disk;
|
|
|
|
|
+ $ENV{'MOZ_NO_REMOTE'} = '1'; # able to launch multiple instances
|
|
|
|
|
+ $ENV{'MOZ_CRASHREPORTER_DISABLE'} = '1'; # disable breakpad
|
|
|
|
|
+ $ENV{'NO_EM_RESTART'} = '1'; # prevent the binary from detaching from the console.log
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
1;
|
|
1;
|