Branch Coverage

blib/lib/WWW/Mechanize/Chrome.pm
Criterion Covered Total %
branch 39 812 4.8


line true false branch
433 2 0 unless $program
441 0 0 if ($^O =~ /mswin/i)
446 0 0 if ($options->{'pipe'}) { }
451 0 0 unless exists $options->{'port'}
453 0 0 if (exists $options->{'port'})
459 0 0 if ($options->{'listen_host'} or $options->{'host'})
465 0 0 if ($options->{'incognito'})
469 0 0 if ($options->{'data_directory'})
473 0 0 if (my $profile = $options->{'profile'})
474 0 0 if (not $options->{'data_directory'}) { }
0 0 elsif ($profile =~ m([/\\])) { }
478 0 0 if ($rel =~ m([/\\])) { }
488 0 0 if (not exists $options->{'enable_automation'} or $options->{'enable_automation'})
492 0 0 unless (exists $options->{'enable_first_run'} and $options->{'enable_first_run'})
496 0 0 if (not exists $options->{'mute_audio'} or $options->{'mute_audio'})
501 0 0 unless ($no_sandbox)
505 0 0 if ($no_sandbox)
509 0 0 if ($options->{'hide_scrollbars'})
514 0 0 if ($options->{'safebrowsing_auto_update'}) { }
519 0 0 unless (exists $options->{'default_browser_check'} and $options->{'default_browser_check'})
523 0 0 if (exists $options->{'disable_prompt_on_repost'})
543 0 0 if (not exists $options->{$option}) { }
0 0 elsif (not my $value = delete $options->{$option}) { }
551 0 0 if $options->{'headless'}
554 0 0 if exists $options->{'start_url'}
556 0 0 $^O =~ /mswin/i && $program =~ /[\s|<>&]/ ? :
597 129 2 unless (@program_names)
598 0 129 $^O =~ /darwin/i ? :
0 129 $^O =~ /mswin/i ? :
610 0 130 if ($os_style =~ /MSWin/i) { }
0 130 elsif ($os_style =~ /darwin/i) { }
633 1 130 unless (ref $program)
638 0 131 if (my($first_program) = grep({-x $_;} @$program))
646 130 1 if (@without_path)
657 0 3438 if (-x $this)
664 131 0 if (wantarray) { }
666 131 0 unless ($found)
678 0 0 unless "IO::Socket::INET"->new("Listen", 5, "Proto", "tcp", "Reuse", 1, "LocalPort", $port)
699 0 0 if ($socket)
705 0 0 if time - $t < 1
712 0 0 if $method ne "websocket"
736 0 0 if ($method eq 'pipe') { }
757 0 0 unless defined(my $pid = fork)
758 0 0 if ($pid)
768 0 0 unless chdir "/"
769 0 0 unless setsid() != -1
770 0 0 unless open STDIN, "< /dev/null"
771 0 0 if ('pipe' eq $method) { }
772 0 0 unless open STDERR, ">&", "STDOUT"
773 0 0 unless open STDOUT, "> /dev/null"
775 0 0 unless open STDERR, ">&", $child{'stdout'}
776 0 0 unless open STDOUT, ">&", $child{'stdout'}
780 0 0 if ($method eq "pipe")
785 0 0 unless open $from_chrome, "<&", $child{'read'}
786 0 0 unless open $to_chrome, ">&", $child{'write'}
799 0 0 if ($^O =~ /mswin/i) { }
815 0 0 unless defined $line
818 0 0 if ($line =~ /^DevTools listening on (ws:\S+)$/) { }
0 0 elsif ($line =~ /ERROR:headless_shell.cc/) { }
836 0 0 if @_ == 2
846 0 0 if (not @args) { }
850 0 0 if $logger->$enabled
859 3 0 unless ref $options->{'transport'} or $options->{'transport'} or $ENV{'WWW_MECHANIZE_CHROME_TRANSPORT'}
864 0 1 if ($options->{'pipe'}) { }
868 0 1 unless eval "require $t; 1"
876 1 0 unless (exists $options{'autodie'})
880 1 0 unless (exists $options{'autoclose'})
884 1 0 unless (exists $options{'frames'})
888 1 0 unless (exists $options{'download_directory'})
895 1 0 unless (exists $options{'transport'})
900 1 0 unless exists $options{'start_url'}
907 0 1 if ($options{'separate_session'}) { }
914 0 1 if ($options{'tab'} and $options{'tab'} eq "current")
922 1 0 unless ($options{'port'} or $options{'pid'})
923 0 1 if ($options{'pipe'})
930 1 0 unless (exists $options{'pipe'})
934 0 1 $^O =~ /darwin/i ? :
0 1 $^O =~ /mswin32/i ? :
942 0 1 if ($options{'pid'}) { }
0 1 elsif ($options{'driver'} and $options{'driver_transport'}) { }
0 1 elsif ($options{'port'}) { }
960 0 0 unless ($ok)
973 0 0 if ('pipe' eq $connection_style) { }
0 0 elsif ($options{'endpoint'}) { }
989 0 0 if (my $fn = delete $options{'json_log_file'})
990 0 0 unless open $options{'json_log_fh'}, ">:utf8", $fn
1039 0 0 if ($options->{'connection_style'} eq 'pipe') { }
1044 0 0 if ($chrome_stdout) { }
1051 0 0 unless ($options->{'endpoint'})
1073 0 0 if (not $ok)
1097 0 0 if (ref $args[1] eq "HASH")
1103 0 0 $options{'start_url'} ? :
1116 0 0 if ($err)
1117 0 0 if ($self->{'kill_pid'} and my $pid = delete $self->{'pid'})
1150 0 0 keys %{$options{'extra_headers'};} ? :
1156 0 0 if (my $agent = delete $options{'user_agent'})
1164 0 0 unless (exists $options{'tab'})
1181 0 0 if ($self->{'report_js_errors'})
1225 0 0 if ($^O =~ /darwin/)
1235 0 0 if ($v =~ /^(.*?)\s+(\d+\.\d+\.\d+\.\d+)\b/) { }
0 0 elsif ($v =~ m[^(Mozilla Firefox)[ /](\d+.\d+)\b]) { }
1247 0 0 $options->{'launch_exe'} ? :
1249 0 0 if $error
1256 0 0 if ($name eq 'Microsoft Edge') { }
1259 0 0 if ($v =~ /^11\./) { }
1271 0 1 if (&blessed($self) and $self->target) { }
1 0 elsif (not $^O =~ /mswin/i) { }
1276 0 0 if ($version)
1385 0 0 $options{'tab'} ? :
1428 0 0 if ($popup) { }
1440 0 0 if ($targetInfo->{'params'}{'targetInfo'}{'type'} eq 'page' and not $known_targets{$id}) { }
1463 0 0 if @_ == 2
1480 0 0 if (exists $options{'javascript'})
1481 0 0 !$options{'javascript'} ? :
1591 0 0 unless (defined wantarray)
1621 0 0 if ($cb) { }
1626 0 0 if ($s->{'on_request_intercepted'})
1681 0 0 if ($cb) { }
1686 0 0 if ($s->{'on_dialog'})
1710 0 0 $accept ? :
1712 0 0 defined $prompt ? :
1806 0 0 if ($result->{'error'}) { }
0 0 elsif ($result->{'exceptionDetails'}) { }
1821 0 0 if (exists $result->{'result'}{'value'}) { }
1884 0 0 if (not $options{'objectId'}) { }
1899 0 0 if ($result->{'error'}) { }
0 0 elsif ($result->{'exceptionDetails'}) { }
1913 0 0 if (exists $result->{'result'}{'value'}) { }
1942 0 0 if ($ua)
1973 0 1 if ($_[0]{'autoclose'} and $_[0]->target and $_[0]->tab)
1986 0 1 if ($_[0]{'driver'})
1995 0 1 if ($_[0]{'autoclose'} and $_[0]{'kill_pid'})
2001 0 0 if ($pid and kill 0, $pid)
2004 0 0 if (not kill($signal, $pid)) { }
2011 0 0 if ($^O =~ /darwin/i) { }
2017 0 0 if ($res != -1 and $res != $pid) { }
2018 0 0 if $res != 0
2032 0 0 if ($res) { }
2042 0 0 if (my $path = $wait_file)
2045 0 0 unless -e $path
2046 0 0 if unlink $path
2159 0 0 unless ref $predicate eq "CODE"
2168 0 0 if (&$predicate($events[-1]))
2180 0 0 if ($ev->{'method'} eq "Page.frameStartedLoading" or $ev->{'method'} eq "Page.frameScheduledNavigation" or $ev->{'method'} eq "Network.requestWillBeSent")
2191 0 0 if ($ev->{'method'} eq "Page.frameStartedLoading" or $ev->{'method'} eq "Page.frameScheduledNavigation" or $ev->{'method'} eq "Network.requestWillBeSent")
2196 0 0 if ($requestId) { }
2218 0 0 if $requestId
2226 0 0 unless ($ev->{'method'})
2298 0 0 if ($ev->{'method'} eq 'Page.frameResized' and 0 + keys(%{$$ev{'params'};}) == 0) { }
0 0 elsif ($ev->{'method'} eq 'Inspector.detached') { }
0 0 elsif ($ev->{'method'} eq 'Page.navigatedWithinDocument') { }
2371 0 0 if (not $options{'intrapage'} and $navigated) { }
2444 0 0 if (exists $options{'basedir'}) { }
2455 0 0 if ($^O =~ /mswin/i) { }
2535 0 0 if $body_obj->{'base64Encoded'}
2555 0 0 if ($requestId)
2568 0 0 if ($ct =~ m[^text/(\w+); charset=(.*?)]) { }
2604 0 0 if ($url)
2607 0 0 unless $_->{'method'}
2608 0 0 if (defined $frameId and $_->{'method'} eq "Network.requestWillBeSent" and $_->{'params'}{'frameId'} eq $frameId)
2611 0 0 if ($url and $_->{'params'}{'request'}{'url'} eq $url) { }
2621 0 0 unless (defined $requestId)
2624 0 0 unless (defined $frameId)
2631 0 0 if (exists $_->{'params'}{'requestId'} and $_->{'params'}{'requestId'} eq $requestId) { }
0 0 elsif (not exists $_->{'params'}{'requestId'} and $this_frame eq $frameId) { }
2647 0 0 if ($_->{'method'} eq "Network.requestWillBeSent" and $rfi eq $fi)
2667 0 0 if ($about_blank_loaded) { }
0 0 elsif (my $res = $events{'Network.responseReceived'}) { }
0 0 elsif ($res = $events{'Page.navigatedWithinDocument'}) { }
0 0 elsif ($res = $events{'Network.loadingFailed'}) { }
0 0 elsif ($res = $events{'Page.frameNavigated'} and $res->{'params'}{'frame'}{'unreachableUrl'}) { }
0 0 elsif ($res = $events{'Page.frameNavigated'} and $res->{'params'}{'frame'}{'url'} =~ m[^file://]) { }
0 0 elsif ($res = $events{'Page.frameClearedScheduledNavigation'} and $res->{'params'}{'frameId'} eq $frameId) { }
0 0 elsif ($res = $events{'Page.frameStoppedLoading'} and $res->{'params'}{'frameId'} eq $frameId) { }
0 0 elsif ($res = $events{'MechanizeChrome.download'}) { }
2797 0 0 unless ($options{'data'})
2854 0 0 if (exists $options{'ignoreCache'})
2855 0 0 $options{'ignoreCache'} ? :
2879 0 0 if ('' eq $dir) { }
3022 0 0 if ($self->{'autodie'}) { }
3032 0 0 if ($self->{'autodie'}) { }
3033 0 0 if ($self->status and not $self->status =~ /^2/ and $self->status != 0)
3057 0 0 if $res
3190 0 0 if (time - $start_time > $wait_time)
3231 0 0 if ($self->{'_document'}) { }
3262 0 0 if ($ct eq 'text/html') { }
3322 0 0 if ('html' eq $format) { }
0 0 elsif ($format eq 'text') { }
0 0 elsif ($format eq 'mhtml') { }
3383 0 0 if (my($meta) = $self->xpath("//meta[translate(\@http-equiv,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=\"content-type\"]", "first", 1))
3385 0 0 if $ct
3408 0 0 if (not $nodeId) { }
3469 0 0 if $base
3489 0 0 if (my($meta) = $self->xpath("//meta[translate(\@http-equiv,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=\"content-type\"]", "first", 1))
3492 0 0 if (not $ct and my $r = $self->response)
3497 0 0 if defined $ct
3562 0 0 if ($tag)
3563 0 0 if (not exists $link_spec{$tag}) { }
3571 0 0 if ($tag eq "meta")
3573 0 0 if ($content =~ /^\d+\s*;\s*url\s*=\s*(\S+)/i) { }
3575 0 0 unless $url =~ s/^"(.+)"$/$1/
3582 0 0 if (defined $url) { }
3627 0 0 if ("ARRAY" ne (ref $query || ''))
3630 0 0 $options{'node'} ? :
3718 0 0 unless $xpath_quote{$1}
3727 0 0 unless keys %$p
3729 0 0 if defined $p->{'url'} and not $link->url eq $p->{'url'}
3730 0 0 if defined $p->{'url_regex'} and not $link->url =~ /$p->{'url_regex'}/
3731 0 0 if defined $p->{'url_abs'} and not $link->url_abs eq $p->{'url_abs'}
3732 0 0 if defined $p->{'url_abs_regex'} and not $link->url_abs =~ /$p->{'url_abs_regex'}/
3733 0 0 if defined $p->{'text'} and not defined $link->text && $link->text eq $p->{'text'}
3734 0 0 if defined $p->{'text_regex'} and not defined $link->text && $link->text =~ /$p->{'text_regex'}/
3735 0 0 if defined $p->{'name'} and not defined $link->name && $link->name eq $p->{'name'}
3736 0 0 if defined $p->{'name_regex'} and not defined $link->name && $link->name =~ /$p->{'name_regex'}/
3737 0 0 if defined $p->{'tag'} and not $link->tag && $link->tag eq $p->{'tag'}
3738 0 0 if defined $p->{'tag_regex'} and not $link->tag && $link->tag =~ /$p->{'tag_regex'}/
3740 0 0 if defined $p->{'id'} and not $link->attrs->{'id'} && $link->attrs->{'id'} eq $p->{'id'}
3741 0 0 if defined $p->{'id_regex'} and not $link->attrs->{'id'} && $link->attrs->{'id'} =~ /$p->{'id_regex'}/
3742 0 0 if defined $p->{'class'} and not $link->attrs->{'class'} && $link->attrs->{'class'} eq $p->{'class'}
3743 0 0 if defined $p->{'class_regex'} and not $link->attrs->{'class'} && $link->attrs->{'class'} =~ /$p->{'class_regex'}/
3758 0 0 if (exists $opts{$_})
3765 0 0 if ($single and exists $opts{'n'})
3769 0 0 if $n ne "all"
3788 0 0 if length $op
3791 0 0 if (exists $opts{$key})
3798 0 0 if (my $p = delete $opts{'url'})
3802 0 0 if (my $p = delete $opts{'tag'})
3805 0 0 if (my $p = delete $opts{'tag_regex'})
3810 0 0 exists $link_spec{$_} ? :
3812 0 0 if (@full) { }
3822 0 0 if (keys %opts)
3832 0 0 if ($one)
3833 0 0 if (0 == @res)
3834 0 0 if ($single)
3835 0 0 if (1 < @res)
3844 0 0 if ($n eq "all")
3868 0 0 if "all" eq ($opts{'n'} || '')
3869 0 0 if (my $link = $self->find_link_dom('frames', 0, %opts)) { }
3898 0 0 if wantarray
3921 0 0 if wantarray
3941 0 0 if (@_ == 2) { }
3961 0 0 unless ($doc->{'__path'})
3977 0 0 unless ($just_parent)
3984 0 0 if ("html" ne $tag and "" ne $tag)
3994 0 0 if ($body)
4095 0 0 if ($node->{'children'})
4132 0 0 if ($retry)
4145 0 0 if ($retry)
4154 0 0 if ($results->{'resultCount'}) { }
4164 0 0 if (defined $subTreeId) { }
4199 0 0 if ($response->{'nodeIds'}[0] == 0)
4227 0 0 if ($node->{'children'})
4248 0 0 if (ref $node_ids{$nid}{'attributes'} eq "ARRAY")
4277 0 0 unless (defined $id)
4287 0 0 if (my $n = $nodes->{$id})
4291 0 0 unless ($_->{'backendNodeId'})
4301 0 0 if ($subTreeId) { }
4315 0 0 if ($node->{'backendNodeId'} == $subTreeId)
4322 0 0 if ($inSubTree and exists $foundNodes{$node->{'nodeId'}})
4326 0 0 if ($node->{'children'})
4349 0 0 if ("ARRAY" ne (ref $query || ''))
4352 0 0 unless (exists $options{'frames'})
4361 0 0 if ($index >= 1)
4373 0 0 unless (exists $options{'all'} or $return_first_element)
4374 0 0 if defined wantarray and not wantarray
4383 0 0 if ($options{'document'})
4397 0 0 if ($options{'node'}) { }
4409 0 0 @r ? :
4421 0 0 if (not $zero_allowed and @res == 0)
4424 0 0 if (not $two_allowed and @res > 1)
4430 0 0 $return_first_element ? :
4452 0 0 if ("ARRAY" ne (ref $query || ''))
4530 0 0 if (not defined $name) { }
0 0 elsif (ref $name and &blessed($name) and $name->isa('WWW::Mechanize::Chrome::Node')) { }
0 0 elsif (ref $name eq 'HASH') { }
4540 0 0 if (exists $options{'text'})
4544 0 0 if (exists $options{'name'})
4549 0 0 if ($options{'name'} eq "")
4557 0 0 if ($options{'dom'}) { }
4590 0 0 if (exists $options{$meth})
4596 0 0 unless $method
4604 0 0 unless (grep {exists $options->{$_};} "single", "one", "maybe", "all", "any")
4652 0 0 if (exists $options{'input'}) { }
0 0 elsif (exists $options{'name'}) { }
0 0 elsif (exists $options{'value'}) { }
0 0 elsif (exists $options{'id'}) { }
0 0 elsif (exists $options{'number'}) { }
4676 0 0 if ($node) { }
4706 0 0 unless $self->{'current_form'}
4724 0 0 unless ($focus)
4756 0 0 if ($type = $f->get_attribute('type', 'live', 1) || '')
4848 0 0 if (ref $fields[0] eq "HASH")
4884 0 0 wantarray ? :
4915 0 0 if (ref $index)
4961 0 0 if (defined $options{'delay'})
5000 0 0 unless ref $value
5006 0 0 if (@fields)
5044 0 0 if (@_ == 3) { }
5047 0 0 if (defined $index and not $index =~ /^\d+$/)
5086 0 0 if ($name =~ s/^\^//) { }
0 0 elsif ($name =~ s/^#//) { }
0 0 elsif ($name =~ s/^\.//) { }
5093 0 0 if (&blessed($name)) { }
5118 0 0 if defined $pre and not ref $pre
5121 0 0 if defined $post and not ref $post
5126 0 0 unless my $obj = delete $options{'field'}
5135 0 0 if (lc $tag eq "input" and $obj->get_attribute("type", "live", 1) eq "radio")
5140 0 0 unless ($id)
5163 0 0 if ('value' eq $method) { }
0 0 elsif ('selected' eq $method) { }
0 0 elsif ('checked' eq $method) { }
0 0 elsif ('content' eq $method) { }
5168 0 0 if (defined $value)
5170 0 0 unless ref $value
5195 0 0 if (defined $value)
5196 0 0 unless ref $value
5234 0 0 if defined $pre and not ref $pre
5237 0 0 if defined $post and not ref $post
5245 0 0 if (defined $index)
5246 0 0 if ($index == 1 or $index =~ /[^1]1$/) { }
0 0 elsif ($index == 2 or $index =~ /[^1]2$/) { }
0 0 elsif ($index == 3 or $index =~ /[^1]3$/) { }
5265 0 0 if (my $obj = $fields[0]) { }
5267 0 0 if ($set_value)
5277 0 0 unless defined wantarray
5282 0 0 if ('SELECT' eq uc $tag) { }
5284 0 0 unless ($id)
5306 0 0 if (wantarray) { }
5345 0 0 unless (eval {
5363 0 0 if ('HASH' eq ref $value or '') { }
0 0 elsif ('ARRAY' eq ref $value or '') { }
5365 0 0 unless $_ eq "n"
5370 0 0 ref $value->{'n'} ? :
5379 0 0 if ($deselect)
5385 0 0 if ($single)
5387 0 0 0 + @by_index ? :
5388 0 0 0 + @by_value ? :
5426 0 0 if (not defined $name) { }
0 0 elsif (ref $name and &blessed($name)) { }
0 0 elsif (ref $name eq 'HASH') { }
5436 0 0 if (exists $options{'name'})
5438 0 0 if ($name =~ s/^\^//) { }
0 0 elsif ($name =~ s/^#//) { }
0 0 elsif ($name =~ s/^\.//) { }
5446 0 0 if $value
5463 0 0 defined $value ? :
5468 0 0 if ($options{'dom'}) { }
5476 0 0 if ($set xor $is_set)
5477 0 0 if ($set) { }
5514 0 0 if ($dom_form) { }
5585 0 0 unless ($form)
5586 0 0 if ($fields = delete $options{'with_fields'}) { }
5589 0 0 unless ($form)
5599 0 0 unless ($form)
5608 0 0 if ($options{'button'}) { }
5641 0 0 unless ($f)
5653 0 0 if (ref $v)
5703 0 0 if (2 == @_) { }
5709 0 0 unless ($options{'dom'})
5714 0 0 unless $options{'dom'}
5760 0 0 unless $type eq "boolean"
5813 0 0 if (2 == @_) { }
5826 0 0 if ($timeout)
5833 0 0 unless ($node)
5837 0 0 unless $node
5844 0 0 if ($v and $timeout and time >= $timeout_after)
5845 0 0 if ($wait) { }
5893 0 0 if ($timeout)
5902 0 0 if (@nodes)
5907 0 0 if (time >= $timeout_after)
5944 0 0 if (scalar keys %$rect)
5948 0 0 if (scalar keys %$target)
5951 0 0 if $target->{'height'}
5953 0 0 if $target->{'width'}
5975 0 0 ref $url_or_resource ? :
5976 0 0 if ref $url_or_resource
5979 0 0 if (delete $result->{'base64Encoded'}) { }
6012 0 0 if ($$seen{$res->{'url'}})
6016 0 0 unless (&$wanted($res))
6023 0 0 if (exists $$names{$res->{'url'}}) { }
6048 0 0 if ($save)
6059 0 0 if (my $t = $tree->{'childFrames'})
6108 0 0 unless my $target_file = $options{'target_file'}
6110 0 0 unless (defined $target_dir)
6113 0 0 unless (-e $target_dir)
6114 0 0 unless mkdir $target_dir
6135 0 0 unless my $target = $names{$resource->{'url'}}
6137 0 0 unless open my $fh, ">", $target
6139 0 0 if ($resource->{'_utf8'}) { }
6190 0 0 if (keys %$params) { }
6215 0 0 unless (exists $params->{$field})
6266 0 0 unless my $element = delete $options{'element'}
6347 0 0 if ($fmt eq 'png') { }
0 0 elsif ($fmt eq 'pdf') { }
6353 0 0 if (defined $filename)
6354 0 0 unless open my $fh, ">:raw", $filename
6396 0 0 if (my $format = delete $options{'format'})
6397 0 0 unless my $wh = $PaperFormats{lc $format}
6404 0 0 if (my $filename = delete $options{'filename'})
6405 0 0 unless open my $fh, ">:raw", $filename
6449 0 0 if ($self->{'report_js_errors'})
6450 0 0 if (my(@errors) = $self->js_errors)
6463 0 0 @{$_->{'trace'};} ? :
0 0 @{$_->{'trace'};} && $_->{'trace'}[-1]{'function'} ? :
6465 0 0 if @errors
6513 0 0 if ($callback) { }