From 563d2c20972d812ce78289492abae5da2b98c144 Mon Sep 17 00:00:00 2001 From: Philipp Voglhofer Date: Fri, 9 Oct 2020 10:00:06 +0200 Subject: [PATCH 1/2] Disregard all about: uris in the navigation policy. We already discovered issues with about:blank requests, as these are not regular navigation requests. These peculiarities extend to other about: requests as well, so they should be disregarded in the decide-policy handling too. --- lib/WWW/WebKit2.pm | 3 +-- t/iframe_open.t | 21 +++++++++++++++++++++ t/test/iframe.html | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 t/iframe_open.t create mode 100644 t/test/iframe.html diff --git a/lib/WWW/WebKit2.pm b/lib/WWW/WebKit2.pm index 7b246d1..aba505d 100644 --- a/lib/WWW/WebKit2.pm +++ b/lib/WWW/WebKit2.pm @@ -361,8 +361,7 @@ sub init_webkit { my $action = $decision->get_navigation_action; my $action_uri = $action->get_request->get_uri; - unless ($action_uri eq 'about:blank') { - + unless ($action_uri =~ m/\A about:/x) { if ($self->concurrent_active_navigation_warning and $self->active_navigation_action and not $action->is_redirect) { diff --git a/t/iframe_open.t b/t/iframe_open.t new file mode 100644 index 0000000..9b42a94 --- /dev/null +++ b/t/iframe_open.t @@ -0,0 +1,21 @@ +use strict; +use warnings; +use utf8; + +use Test::More; +use lib 'lib'; +use FindBin qw($Bin $RealBin); +use lib "$Bin/../../Gtk3-WebKit2/lib"; +use URI; +use WWW::WebKit2; + +#Running tests as root will sometimes spawn an X11 that cannot be closed automatically and leave the test hanging +plan skip_all => 'Tests run as root may hang due to X11 server not closing.' unless $>; + +my $wkit = WWW::WebKit2->new(xvfb => 1); +$wkit->init; + +$wkit->open("$Bin/test/iframe.html"); +ok(1, 'opened'); + +done_testing; diff --git a/t/test/iframe.html b/t/test/iframe.html new file mode 100644 index 0000000..3898d59 --- /dev/null +++ b/t/test/iframe.html @@ -0,0 +1,23 @@ + + + + + + + + + +
beautiful testpage
+ + + + + + + From e1c17604df52a62765fd9fd3eab133a309859dd1 Mon Sep 17 00:00:00 2001 From: Jason Carty Date: Wed, 21 Oct 2020 11:24:41 +0200 Subject: [PATCH 2/2] Extra test code, within iframe_open. Unset active_navigation_action if it is set and we are trying to navigate to an about* page and if a failed-with-tls-errors happens within the resource-load-started signal. --- lib/WWW/WebKit2.pm | 7 +++++++ t/iframe_open.t | 1 + t/test/iframe.html | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/lib/WWW/WebKit2.pm b/lib/WWW/WebKit2.pm index aba505d..3c3f80e 100644 --- a/lib/WWW/WebKit2.pm +++ b/lib/WWW/WebKit2.pm @@ -375,6 +375,9 @@ sub init_webkit { if ($self->view->get_uri =~ s/#.*//r) ne ($action->get_request->get_uri =~ s/#.*//r) and not $action->is_redirect; } + else { + $self->active_navigation_action(''); + } } $decision->use; @@ -460,6 +463,10 @@ sub handle_resource_request { $self->active_navigation_action('') if $uri eq $self->active_navigation_action; delete $self->pending_requests->{"$request"} if defined $self; }); + $resource->signal_connect('failed-with-tls-errors' => sub { + $self->active_navigation_action('') if $uri eq $self->active_navigation_action; + delete $self->pending_requests->{"$request"} if defined $self; + }); } sub setup_xvfb { diff --git a/t/iframe_open.t b/t/iframe_open.t index 9b42a94..42b336e 100644 --- a/t/iframe_open.t +++ b/t/iframe_open.t @@ -18,4 +18,5 @@ $wkit->init; $wkit->open("$Bin/test/iframe.html"); ok(1, 'opened'); +$wkit->click('id=iframeDisplay'); done_testing; diff --git a/t/test/iframe.html b/t/test/iframe.html index 3898d59..4c9c2b0 100644 --- a/t/test/iframe.html +++ b/t/test/iframe.html @@ -18,6 +18,16 @@ +
+ +
+
+