Skip to content

Commit

Permalink
Properly cast ignoreCache to JSON::true or JSON::false
Browse files Browse the repository at this point in the history
This addresses GH issue #54 reported by Rub3nCT
  • Loading branch information
Max Maischein committed May 1, 2020
1 parent 909a3ad commit eaee005
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/WWW/Mechanize/Chrome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,9 @@ current request.
=cut

sub reload( $self, %options ) {
if( exists $options{ ignoreCache } ) {
$options{ ignoreCache } = $options{ ignoreCache } ? JSON::true : JSON::false;
};
$self->_mightNavigate( sub {
$self->target->send_message('Page.reload', %options )
}, navigates => 1, %options)
Expand Down
7 changes: 5 additions & 2 deletions t/49-mech-nav.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR

# What instances of Chrome will we try?
my @instances = t::helper::browser_instances();
my $testcount = 5;

if (my $err = t::helper::default_unavailable) {
plan skip_all => "Couldn't connect to Chrome: $@";
exit
} else {
plan tests => 4*@instances;
plan tests => 5*@instances;
};

sub new_mech {
Expand All @@ -35,7 +36,7 @@ my $server = Test::HTTP::LocalServer->spawn(
#debug => 1,
);

t::helper::run_across_instances(\@instances, \&new_mech, 4, sub {
t::helper::run_across_instances(\@instances, \&new_mech, $testcount, sub {
my( $file, $mech ) = splice @_; # so we move references

$mech->get($server->url);
Expand All @@ -56,6 +57,8 @@ t::helper::run_across_instances(\@instances, \&new_mech, 4, sub {
#if( $version =~ /\b(\d+)\b/ and $1 < 66 ) {
$mech->reload;
is $mech->uri, $last, 'We reloaded';
$mech->reload( ignoreCache => 1 );
is $mech->uri, $last, 'We reloaded, ignoring the cache';
#} else {
# skip "Chrome v66+ doesn't know how to reload without hanging in a dialog box", 1;
#}
Expand Down

0 comments on commit eaee005

Please sign in to comment.