Firefox-Marionette

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

            $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

lib/Firefox/Marionette.pm  view on Meta::CPAN

    }

    if ( defined $parameters{adb} ) {
        $self->_setup_adb( $parameters{adb}, $parameters{port} );
    }
    if ( defined $parameters{host} ) {
        if ( $OSNAME eq 'MSWin32' ) {
            $parameters{user} ||= Win32::LoginName();
        }
        else {
            $parameters{user} ||= getpwuid $EFFECTIVE_USER_ID;
        }
        if ( $parameters{host} =~ s/:(\d+)$//smx ) {
            $parameters{port} = $1;
        }
        $parameters{port} ||= scalar getservbyname 'ssh', 'tcp';
        $self->_setup_ssh(
            $parameters{host}, $parameters{port},
            $parameters{user}, $parameters{reconnect}
        );
    }

lib/Firefox/Marionette.pm  view on Meta::CPAN

        $host = $self->_ssh()->{host};
        $user = $self->_ssh()->{user};
    }
    elsif (( $OSNAME eq 'MSWin32' )
        || ( $OSNAME eq 'cygwin' ) )
    {
        $user = Win32::LoginName();
        $host = 'localhost';
    }
    else {
        $user = getpwuid $EFFECTIVE_USER_ID;
        $host = 'localhost';
    }
    my $quoted_user = defined $user ? quotemeta $user : q[];
    if ( $self->_ssh() ) {
        $self->_initialise_remote_uname();
    }
    $self->_check_visible(%parameters);
    my $port = $self->_get_marionette_port();
    defined $port
      or Firefox::Marionette::Exception->throw(

lib/Firefox/Marionette/Profile.pm  view on Meta::CPAN

}
our $VERSION = '1.67';

sub ANY_PORT            { return 0 }
sub _GETPWUID_DIR_INDEX { return 7 }

sub profile_ini_directory {
    my $profile_ini_directory;
    if ( $OSNAME eq 'darwin' ) {
        my $home_directory =
          ( getpwuid $EFFECTIVE_USER_ID )[ _GETPWUID_DIR_INDEX() ];
        defined $home_directory
          or Firefox::Marionette::Exception->throw(
            "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR");
        $profile_ini_directory = File::Spec->catdir( $home_directory, 'Library',
            'Application Support', 'Firefox' );
    }
    elsif ( $OSNAME eq 'MSWin32' ) {
        $profile_ini_directory =
          File::Spec->catdir( Win32::GetFolderPath( Win32::CSIDL_APPDATA() ),
            'Mozilla', 'Firefox' );
    }
    elsif ( $OSNAME eq 'cygwin' ) {
        $profile_ini_directory =
          File::Spec->catdir( $ENV{APPDATA}, 'Mozilla', 'Firefox' );
    }
    else {
        my $home_directory =
          ( getpwuid $EFFECTIVE_USER_ID )[ _GETPWUID_DIR_INDEX() ];
        defined $home_directory
          or Firefox::Marionette::Exception->throw(
            "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR");
        $profile_ini_directory =
          File::Spec->catdir( $home_directory, '.mozilla', 'firefox' );
    }
    return $profile_ini_directory;
}

sub _read_ini_file {
    my ( $class, $profile_ini_directory, $handle ) = @_;
    if ( defined $handle ) {
        my $config = Config::INI::Reader->read_handle($handle);

lib/Firefox/Marionette/Profile.pm  view on Meta::CPAN

accepts a key name (such as C<browser.startup.homepage>) and a value (such as C<https://duckduckgo.com>) and sets this value in the profile.  It returns itself to aid in chaining methods

=head2 clear_value

accepts a key name (such as C<browser.startup.homepage>) and removes the key from the profile.  It returns the old value of the key (if any).

=head1 DIAGNOSTICS

=over
 
=item C<< Failed to execute getpwuid for %s:%s >>
 
The module was unable to to execute L<perlfunc/getpwuid>.  This is probably a bug in this module's logic.  Please report as described in the BUGS AND LIMITATIONS section below.

=item C<< Failed to open '%s' for writing:%s >>
 
The module was unable to open the named file.  Maybe your disk is full or the file permissions need to be changed?

=item C<< Failed to write to '%s':%s >>
 
The module was unable to write to the named file.  Maybe your disk is full?

=item C<< Failed to close '%s':%s >>

lib/Waterfox/Marionette/Profile.pm  view on Meta::CPAN

        require Win32;
    }
}
our $VERSION = '1.67';

sub profile_ini_directory {
    my ($class) = @_;
    my $profile_ini_directory;
    if ( $OSNAME eq 'darwin' ) {
        my $home_directory =
          ( getpwuid $EFFECTIVE_USER_ID )
          [ $class->SUPER::_GETPWUID_DIR_INDEX() ];
        defined $home_directory
          or Firefox::Marionette::Exception->throw(
            "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR");
        $profile_ini_directory = File::Spec->catdir( $home_directory, 'Library',
            'Application Support', 'Waterfox' );
    }
    elsif ( $OSNAME eq 'MSWin32' ) {
        $profile_ini_directory =
          File::Spec->catdir( Win32::GetFolderPath( Win32::CSIDL_APPDATA() ),
            'Waterfox', 'Waterfox' );
    }
    elsif ( $OSNAME eq 'cygwin' ) {
        $profile_ini_directory =
          File::Spec->catdir( $ENV{APPDATA}, 'Waterfox', 'Waterfox' );
    }
    else {
        my $home_directory =
          ( getpwuid $EFFECTIVE_USER_ID )
          [ $class->SUPER::_GETPWUID_DIR_INDEX() ];
        defined $home_directory
          or Firefox::Marionette::Exception->throw(
            "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR");
        $profile_ini_directory =
          File::Spec->catdir( $home_directory, '.waterfox' );
    }
    return $profile_ini_directory;
}

sub new {
    my ( $class, %parameters ) = @_;
    my $profile = bless { comments => q[], keys => {} }, $class;
    $profile->set_value( 'bookmarks.initialized.pref', 'true', 0 );

ssh-auth-cmd-marionette  view on Meta::CPAN

      qr/kill[ ]\-0[ ]\d{1,8}/smx,
      qr/which[ ]$allowed_binary_regex/smx,
      qr/readlink[ ]\-f[ ]$allowed_binary_paths_regex/smx,
qr/rm[ ]\-Rf[ ]$root_dir_regex(?:[ ]$quoted_tmp_directory\/Temp\-[\d\-a-f]{1,255})*/smx,
qr/ls[ ]-1[ ]"$allowed_binary_directories_regex(?:\/updates(?:\/\d+)?)?"/smx,
      qr/ls[ ]-1[ ]"$root_dir_regex\/downloads"/smx,
      qr/certutil$certutil_arguments_regex/smx,
      qr/(?:$xvfb_regex)?"$allowed_binary_regex"$firefox_arguments_regex/smx,
      qr/grep[ ]$prefs_grep_patterns_regex$profile_path_regex\/prefs[.]js/smx;

    my $user_name = getpwuid $EFFECTIVE_USER_ID;
    if ( $ENV{SSH_ORIGINAL_COMMAND} =~ m/^($allowed_commands_regex)$/smx ) {
        my ($command_and_arguments) = ($1);
        if ( $options{'force-binary'} ) {
            $command_and_arguments =~
              s/^"$allowed_binary_regex"/"$options{'force-binary'}"/smx;
        }
        Sys::Syslog::openlog( $ident, 'cons', $options{facility} );
        Sys::Syslog::syslog( Sys::Syslog::LOG_INFO(),
            "Executing '$command_and_arguments' as '$user_name' from "
              . _origin() );

t/01-marionette.t  view on Meta::CPAN

my $dummy2_uri = 'data:application/json,{"latitude":40.7,"longitude":-73.9,"time_zone":{"current_time":"1234abc"}}'; # dummy data for testing bad data
my $most_common_useragent = q[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36];
my $useragents_me_uri = qq[data:application/json,{"about": "Use this API to get a list of current popular useragents. Please post a link back to the site if you find it useful!", "terms": "As the data here don't change sooner than once per week, you ...

my $min_geo_version = 60;
my $min_stealth_version = 59;

if (($^O eq 'MSWin32') || ($^O eq 'cygwin')) {
} elsif ($> == 0) { # see RT#131304
       my $current = $ENV{HOME};
       my $correct = (getpwuid($>))[7];
       if ($current eq $correct) {
       } else {
               $ENV{HOME} = $correct;
               diag("Running as root.  Resetting HOME environment variable from $current to $ENV{HOME}");
               diag("Could be running in an environment where sudo does not reset the HOME environment variable, such as ubuntu");
       }
       foreach my $env_name (
				'XAUTHORITY',           # see GH#1
				'XDG_RUNTIME_DIR',      # see GH#33
                         ) {

t/01-marionette.t  view on Meta::CPAN

	my $argument_string = q[];
	if ($ENV{FIREFOX_VISIBLE}) {
		$argument_string = q[visible => 1];
	}
	my $exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', "my \$f = Firefox::Marionette->new($argument_string); exit 0";
	ok($exit_status == 0, "Firefox::Marionette doesn't alter the exit code of the parent process if it isn't closed cleanly");
	$exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', "my \$f = Firefox::Marionette->new($argument_string); \$f = undef; exit 0";
	ok($exit_status == 0, "Firefox::Marionette doesn't alter the exit code of the parent process if it is 'undefed'");
	if ($ENV{RELEASE_TESTING}) {
		if ($ENV{FIREFOX_HOST}) {
			my $user = getpwuid($>);;
			my $host = $ENV{FIREFOX_HOST};
			if ($ENV{FIREFOX_USER}) {
				$user = $ENV{FIREFOX_USER};
			} elsif (($ENV{FIREFOX_HOST} eq 'localhost') && (!$ENV{FIREFOX_PORT})) {
				$user = 'firefox';
			}
			my $handle = File::Temp->new( TEMPLATE => File::Spec->catfile( File::Spec->tmpdir(), 'firefox_test_ssh_local_directory_XXXXXXXXXXX')) or Firefox::Marionette::Exception->throw( "Failed to open temporary file for writing:$!");
			fcntl $handle, Fcntl::F_SETFD(), 0 or Carp::croak("Can't clear close-on-exec flag on temporary file:$!");
			my $via = $ENV{FIREFOX_VIA} ? q[, via => "] . $ENV{FIREFOX_VIA} . q["] : q[];
			my $handle_fileno = fileno $handle;

t/author/bulk_test.pl  view on Meta::CPAN

		foreach my $name ($csv->header($handle, { detect_bom => 1, munge_column_names => sub { lc (s/[ ]/_/grsmx ) }})) {
			$headers{$name} = $count;
			$count += 1;
		}
		while (my $row = $csv->getline ($handle)) {
			my $server = {};
			foreach my $key (sort { $a cmp $b } keys %headers) {
				$server->{$key} = $row->[$headers{$key}];
			}
			$server->{port} ||= $server->{os} eq 'android' ? 5555 : 22;
			$server->{user} ||= getpwuid $UID;
			push @servers, $server;
		}
		close $handle or die "Failed to close $servers_path:$EXTENDED_OS_ERROR";
	} elsif ($OS_ERROR == POSIX::ENOENT()) {
	} else {
		die "Failed to open $servers_path for reading: $EXTENDED_OS_ERROR";
	}

	my $win32_remote_alarm = 7800;
	my $win32_via_alarm = 7800;

t/author/bulk_test.pl  view on Meta::CPAN

							_wait_for_server_to_boot($server);
							_cleanup_server($server);
							my $remote_tmp_directory = join q[], _remote_contents($server, undef, 'echo %TMP%');
							$remote_tmp_directory =~ s/[\r\n]+$//smx;
							$remote_tmp_directory =~ s/\\/\//smxg;
							if (!$remote_tmp_directory) {
								die "Unable to find remote temp directory";
							}
							my $cygwin_tmp_directory = $remote_tmp_directory;
							$cygwin_tmp_directory =~ s/^C:/\/cygdrive\/c/smx;
							my $local_username = getpwuid $EFFECTIVE_USER_ID;
							$server->{cygwin_command} = "cd $cygwin_tmp_directory";
							_cleanup_cygwin($server);
							my $cover_db_format = join q[], _remote_contents($server, undef, 'echo %DEVEL_COVER_DB_FORMAT%');
							$cover_db_format =~ s/[\r\n]+$//smx;
							$cover_db_format =~ s/\\/\//smxg;
							if ($cover_db_format ne $devel_cover_db_format) {
								die "Bad DEVEL_COVER_DB_FORMAT Environment variable";
							}
							my $count = 0;
							REMOTE_WIN32_FIREFOX: {

t/author/bulk_test.pl  view on Meta::CPAN

						my $via_address;
						my $remote_address;
						my $remote_user;
						foreach my $remote (@servers) {
							if ((lc $remote->{type}) eq 'virsh') {
								if ($remote->{os} eq 'win32') {
									while (!_virsh_node_running($remote)) {
										sleep 5;
									}
									_determine_address($remote);
									my $local_username = getpwuid $EFFECTIVE_USER_ID;
									my $jump_ip_address = _get_best_local_ip_match($server->{address});
									$via_address = 'jump' . q[@] . $jump_ip_address;
									$remote_user = $remote->{user};
									$remote_address = $remote->{address};
								}
							}
						}
						foreach my $command (
										{ alarm_after => $win32_via_alarm, command_line => "DEVEL_COVER_DB_FORMAT=JSON RELEASE_TESTING=1 FIREFOX_VIA=$via_address FIREFOX_USER=$remote_user FIREFOX_HOST=$remote_address FIREFOX_NO_RECONNECT=1 FIREFOX_NO_UPDATE=1 perl$devel_cover_inc...
										{ alarm_after => $physical_local_alarm, command_line => "DEVEL_COVER_DB_FORMAT=JSON FIREFOX_NO_VISIBLE=1 RELEASE_TESTING=1 FIREFOX_NO_UPDATE=1 perl$devel_cover_inc_with_space -Ilib $test_marionette_file" },



( run in 0.373 second using v1.01-cache-2.11-cpan-8d75d55dd25 )