Firefox-Marionette
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::Spec();
use Fcntl();
use English qw( -no_match_vars );
sub _win32_registry_query_key {
my (%parameters) = @_;
my $binary = 'reg';
my @parameters =
( 'query', q["] . ( join q[\\], @{ $parameters{subkey} } ) . q["] );
if ( $parameters{name} ) {
push @parameters, ( '/v', q["] . $parameters{name} . q["] );
}
my @values;
my $command = join q[ ], $binary, @parameters;
my $reg_query = `$command 2>nul`;
if ( defined $reg_query ) {
foreach my $line ( split /\r?\n/smx, $reg_query ) {
if ( defined $parameters{name} ) {
my $name =
$parameters{name} eq q[] ? '(Default)' : $parameters{name};
my $quoted_name = quotemeta $name;
if ( $line =~
/^[ ]+${quoted_name}[ ]+(?:REG_SZ)[ ]+(\S.*\S)\s*$/smx )
{
push @values, $1;
}
}
else {
push @values, $line;
}
}
}
return @values;
}
sub _cygwin_reg_query_value {
my ($path) = @_;
sysopen my $handle, $path, Fcntl::O_RDONLY();
my $value;
if ( defined $handle ) {
no warnings;
while ( read $handle, my $buffer, 1 ) {
$value .= $buffer;
}
use warnings;
if ( defined $value ) {
$value =~ s/\0$//smx;
}
}
return $value;
}
if ( ( $OSNAME eq 'MSWin32' ) || ( $OSNAME eq 'cygwin' ) ) {
}
elsif ( $EFFECTIVE_USER_ID == 0 ) { # see RT#131304
my $current = $ENV{HOME};
my $correct = ( getpwuid $EFFECTIVE_USER_ID )[7];
if ( $current eq $correct ) {
}
else {
$ENV{HOME} = $correct;
warn
"Running as root. Resetting HOME environment variable from $current to $ENV{HOME}\n";
}
foreach my $env_name (
'XAUTHORITY', # see GH#1
'XDG_RUNTIME_DIR', # see GH#33
) {
if ( exists $ENV{$env_name} ) {
delete $ENV{$env_name};
warn "Running as root. Deleting the $env_name environment variable\n";
}
}
}
my @possibles = qw(firefox waterfox basilisk);
my $dev_null = File::Spec->devnull();
sub last_desperate_search {
if ( ( $OSNAME eq 'MSWin32' ) ) {
foreach my $possible (@possibles) {
my $output = `"$possible.exe" -version`;
if ($output) {
warn
"Version of $possible in Path environment variable:$output";
}
else {
warn "No $possible in Path environment variable";
}
}
}
elsif ( ( $OSNAME eq 'darwin' ) or ( $OSNAME eq 'cygwin' ) ) {
foreach my $possible (@possibles) {
my $output = `$possible -version`;
if ($output) {
warn
"Version of $possible in PATH environment variable:$output";
}
else {
warn "No $possible in PATH environment variable";
}
}
}
my $glob_path = '/usr/share/applications/firefox*.desktop';
foreach my $path ( glob $glob_path ) {
warn
`$EXECUTABLE_NAME -nle 'print "\$ARGV:\$_" if (/(Exec|^\\[)/);' $path`;
}
return;
}
my $binary; # = 'firefox';
my $suffix =
( ( $OSNAME eq 'MSWin32' ) || ( $OSNAME eq 'cygwin' ) ) ? '.exe' : q[];
my %known_win32_preferred_names = (
'Mozilla Firefox' => 1,
'Mozilla Firefox ESR' => 2,
( run in 2.057 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )