From eaee0052d045755589608de108d3a620dd863ec9 Mon Sep 17 00:00:00 2001 From: Max Maischein Date: Fri, 1 May 2020 19:51:33 +0200 Subject: [PATCH] Properly cast ignoreCache to JSON::true or JSON::false This addresses GH issue #54 reported by Rub3nCT --- lib/WWW/Mechanize/Chrome.pm | 3 +++ t/49-mech-nav.t | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/WWW/Mechanize/Chrome.pm b/lib/WWW/Mechanize/Chrome.pm index 677b6c33..61af4b97 100644 --- a/lib/WWW/Mechanize/Chrome.pm +++ b/lib/WWW/Mechanize/Chrome.pm @@ -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) diff --git a/t/49-mech-nav.t b/t/49-mech-nav.t index 1c95c74b..22dc15e6 100644 --- a/t/49-mech-nav.t +++ b/t/49-mech-nav.t @@ -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 { @@ -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); @@ -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; #}