Skip to content

Commit

Permalink
Create ->eval_in_page_future()
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Maischein committed Apr 7, 2024
1 parent 67305cb commit 7a742de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/WWW/Mechanize/Chrome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1869,15 +1869,18 @@ This method is special to WWW::Mechanize::Chrome.
=cut

sub eval_in_page($self,$str, %options) {
sub eval_in_page_future($self,$str, %options) {
# Report errors from scope of caller
# This feels weirdly backwards here, but oh well:
local @Chrome::DevToolsProtocol::CARP_NOT
= (@Chrome::DevToolsProtocol::CARP_NOT, (ref $self)); # we trust this
local @CARP_NOT
= (@CARP_NOT, 'Chrome::DevToolsProtocol', (ref $self)); # we trust this
my $result = $self->target->evaluate("$str", %options)->get;
return $self->target->evaluate("$str", %options);
}

sub eval_in_page( $self, $str, %options) {
my $result = $self->eval_in_page_future("$str", %options)->get;
if( $result->{error} ) {
$self->signal_condition(
join "\n", grep { defined $_ }
Expand All @@ -1903,6 +1906,7 @@ sub eval_in_page($self,$str, %options) {
{
no warnings 'once';
*eval = \&eval_in_page;
*eval_future = \&eval_in_page_future;
}

=head2 C<< $mech->eval_in_chrome $code, @args >>
Expand Down

0 comments on commit 7a742de

Please sign in to comment.