Firefox-Marionette
view release on metacpan or search on metacpan
t/01-marionette.t view on Meta::CPAN
}
my @names = Firefox::Marionette::Profile->names();
foreach my $name (@names) {
next unless ($name eq 'throw');
$profiles_work = 0;
($skip_message, $firefox) = start_firefox(0, debug => 1, profile_name => $name );
if (!$skip_message) {
$at_least_one_success = 1;
}
if ($skip_message) {
skip($skip_message, 6);
}
ok($firefox, "Firefox loaded with the $name profile");
if ($major_version < 52) {
} elsif (($^O eq 'openbsd') && (Cwd::cwd() !~ /^($quoted_home_directory\/Downloads|\/tmp)/)) {
} else {
my $install_path = Cwd::abs_path('t/addons/test.xpi');
diag("Original install path is $install_path");
if ($^O eq 'MSWin32') {
$install_path =~ s/\//\\/smxg;
}
diag("Installing extension from $install_path");
my $temporary = 1;
my $install_id = $firefox->install($install_path, $temporary);
ok($install_id, "Successfully installed an extension:$install_id");
ok($firefox->uninstall($install_id), "Successfully uninstalled an extension");
}
ok($firefox->go('http://example.com'), "firefox with the $name profile loaded example.com");
ok($firefox->quit() == 0, "firefox with the $name profile quit successfully");
my $profile;
if ($ENV{WATERFOX}) {
$profile = Waterfox::Marionette::Profile->existing($name);
} else {
$profile = Firefox::Marionette::Profile->existing($name);
}
$profile->set_value('security.webauth.webauthn_enable_softtoken', 'true', 0);
($skip_message, $firefox) = start_firefox(0, profile => $profile );
if (defined $ENV{FIREFOX_DEBUG}) {
ok($firefox->debug() eq $ENV{FIREFOX_DEBUG}, "\$firefox->debug() returns \$ENV{FIREFOX_DEBUG}:$ENV{FIREFOX_DEBUG}");
} else {
ok(!$firefox->debug(1), "\$firefox->debug(1) returns false but sets debug to true");
ok($firefox->debug(), "\$firefox->debug() returns true");
}
ok($firefox, "Firefox loaded with a profile copied from $name");
ok($firefox->go('http://example.com'), "firefox with the copied profile from $name loaded example.com");
ok($firefox->quit() == 0, "firefox with the profile copied from $name quit successfully");
$profiles_work = 1;
}
}
if ($ENV{WATERFOX}) {
ok($profile = Waterfox::Marionette::Profile->new(), "Waterfox::Marionette::Profile->new() correctly returns a new profile");
} else {
ok($profile = Firefox::Marionette::Profile->new(), "Firefox::Marionette::Profile->new() correctly returns a new profile");
}
ok(((defined $profile->get_value('marionette.port')) && ($profile->get_value('marionette.port') == 0)), "\$profile->get_value('marionette.port') correctly returns 0");
ok($profile->set_value('browser.link.open_newwindow', 2), "\$profile->set_value('browser.link.open_newwindow', 2) to force new windows to appear");
ok($profile->set_value('browser.link.open_external', 2), "\$profile->set_value('browser.link.open_external', 2) to force new windows to appear");
ok($profile->set_value('browser.block.target_new_window', 'false'), "\$profile->set_value('browser.block.target_new_window', 'false') to force new windows to appear");
$profile->set_value('browser.link.open_newwindow', 2); # open in a new window
$profile->set_value('browser.link.open_newwindow.restriction', 1); # don't restrict new windows
$profile->set_value('dom.disable_open_during_load', 'false'); # don't block popups during page load
$profile->set_value('privacy.popups.disable_from_plugin', 0); # no restrictions
$profile->set_value('security.OCSP.GET.enabled', 'false');
$profile->clear_value('security.OCSP.enabled'); # just testing
$profile->set_value('security.OCSP.enabled', 0);
if ($ENV{FIREFOX_BINARY}) {
$profile->set_value('security.sandbox.content.level', 0, 0); # https://wiki.mozilla.org/Security/Sandbox#Customization_Settings
}
my $correct_exit_status = 0;
my $mozilla_pid_support;
my $original_agent;
my $uname;
my $arch;
my $nightly;
my $developer;
SKIP: {
diag("Initial tests");
($skip_message, $firefox) = start_firefox(0, debug => 1, profile => $profile, mime_types => [ 'application/pkcs10', 'application/pdf' ]);
if (!$skip_message) {
$at_least_one_success = 1;
}
if ($skip_message) {
skip($skip_message, 38);
}
if (defined $ENV{FIREFOX_DEBUG}) {
ok($firefox->debug() eq $ENV{FIREFOX_DEBUG}, "\$firefox->debug() returns \$ENV{FIREFOX_DEBUG}:$ENV{FIREFOX_DEBUG}");
} else {
ok($firefox->debug(), "\$firefox->debug() returns true");
}
ok($firefox, "Firefox has started in Marionette mode");
ok((scalar grep { /^application\/pkcs10$/ } $firefox->mime_types()), "application/pkcs10 has been added to mime_types");
ok((scalar grep { /^application\/pdf$/ } $firefox->mime_types()), "application/pdf was already in mime_types");
ok((scalar grep { /^application\/x\-gzip$/ } $firefox->mime_types()), "application/x-gzip was already in mime_types");
ok((!scalar grep { /^text\/html$/ } $firefox->mime_types()), "text/html should not be in mime_types");
my $capabilities = $firefox->capabilities();
ok(1, "\$capabilities->proxy() " . defined $capabilities->proxy() ? "shows an existing proxy setup" : "is undefined");
$original_agent = $firefox->agent();
$uname = $firefox->uname();
$arch = $firefox->arch();
diag("Browser version is " . $capabilities->browser_version());
if ($firefox->nightly()) {
$nightly = 1;
diag($capabilities->browser_version() . " is a nightly release");
}
if ($firefox->developer()) {
$developer = 1;
diag($capabilities->browser_version() . " is a developer release");
}
($major_version, $minor_version, $patch_version) = split /[.]/smx, $capabilities->browser_version();
if (!defined $minor_version) {
$minor_version = '';
}
if (!defined $patch_version) {
$patch_version = '';
}
diag("Operating System is " . ($capabilities->platform_name() || 'Unknown') . q[ ] . ($capabilities->platform_version() || 'Unknown'));
diag("Profile Directory is " . $capabilities->moz_profile());
diag("Mozilla PID is " . ($capabilities->moz_process_id() || 'Unknown'));
$mozilla_pid_support = defined $capabilities->moz_process_id() ? 1 : 0;
diag("Firefox BuildID is " . ($capabilities->moz_build_id() || 'Unknown'));
diag("Addons are " . ($firefox->addons() ? 'working' : 'disabled'));
diag("User Agent is $original_agent");
( run in 0.591 second using v1.01-cache-2.11-cpan-364913b4093 )