Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/WWW/WebKit2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ WWW::WebKit2 - Perl extension for controlling an embedding WebKit2 engine
WWW::WebKit2 is a drop-in replacement for WWW::Selenium using Gtk3::WebKit2
as browser instead of relying on an external Java server and an installed browser.


There are a range of browser settings available. Please check WWW::WebKit2::Settings for more information.
=head2 EXPORT

None by default.
Expand Down Expand Up @@ -412,7 +414,6 @@ sub process_confirmation_prompt {

}


sub pending {
my ($self) = @_;

Expand All @@ -425,6 +426,13 @@ sub process_events {
Gtk3::main_iteration_do(0) while Gtk3::events_pending;
}

=head2 process_page_load

No parameters needed.
Method attempts to ensure the page has finished loading. This handling is primailary based on checking if GTK3 has any events pending
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*primarily


=cut

sub process_page_load {
my ($self) = @_;

Expand Down Expand Up @@ -557,11 +565,11 @@ sub DESTROY {
=head1 SEE ALSO

See L<WWW::Selenium> for API documentation.
See L<Test::WWW::WebKit> for a replacement for L<Test::WWW::Selenium>.
See L<Test::WWW::WebKit::Catalyst> for a replacement for L<Test::WWW::Selenium::Catalyst>.
See L<Test::WWW::WebKit2> for a replacement for L<Test::WWW::Selenium>.
See L<Test::WWW::WebKit2::Catalyst> for a replacement for L<Test::WWW::Selenium::Catalyst>.

The current development version can be found in the git repository at:
https://github.com/jscarty/WWW-WebKit2
https://github.com/sorryforthecommit/WWW-WebKit2

=head1 AUTHOR

Expand Down
6 changes: 3 additions & 3 deletions lib/WWW/WebKit2/Inspector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sub run_javascript {
my $js_result = '';

$self->view->run_javascript("(function () {$javascript_string})()", undef, sub {
my ($object, $result, $user_data) = @_;
my ($object, $result) = @_;
$done = 1;
$js_result = $self->get_javascript_result($result, $raw, $javascript_string);
}, undef);
Expand Down Expand Up @@ -63,7 +63,7 @@ sub resolve_locator {

$locator =~ s/'/\\'/g;

if (my ($css) = $locator =~ /^css=(.*)/) {
if ($locator =~ /^css=(.*)/) {
return WWW::WebKit2::LocatorCSS->new({
locator_string => $locator,
inspector => $self,
Expand Down Expand Up @@ -113,7 +113,7 @@ sub get_html_source {
return '' unless $resource;

$resource->get_data(undef, sub {
my ($resource, $result, $user_data) = @_;
my ($resource, $result) = @_;

$html_source = $resource->get_data_finish($result);
$done = 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/WWW/WebKit2/Locator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ sub fire_event {
=cut

sub is_visible {
my ($self, $attribute) = @_;
my ($self) = @_;

my $search = $self->prepare_element;

Expand Down
43 changes: 43 additions & 0 deletions lib/WWW/WebKit2/Settings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,49 @@ use Carp qw(carp croak);
use Glib qw(TRUE FALSE);
use Moose::Role;

=head1 NAME

WWW::WebKit2::Settings - setting management methods for webkit2

=cut

=head1 DESCRIPTION

Small list of methods for accessing Webkit2s built in methods. The full list of settings is here
https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html

To enable or disable settings that are not here you can do
$self->settings->SETTINGNAME(TRUE/FALSE)
to enable webkit_settings_set_enable_javascript you just provide

$self->settings->set_enable_javascript(TRUE)

To disable:

$self->settings->set_enable_javascript(FALSE)

To check the status of a setting
$self->settings->get_SETTINGNAME;
if it is active you will get a one if it is not you will get 0
webkit_settings_get_enable_javascript()
$self->settings->get_enable_javascript()

Please note that some settings like
- webkit_settings_set_hardware_acceleration_policy
have specific commands for changing their settings. Please check the Webkit2 documentation for the exact parameters

=cut

=head2 On by default

The settings below are turned on by default when webkit2->init is called.
- webkit_settings_set_enable_developer_extras
- webkit_settings_set_allow_file_access_from_file_urls
- webkit_settings_set_hardware_acceleration_policy

=cut


=head3 enable_file_access_from_file_urls

=cut
Expand Down
1 change: 0 additions & 1 deletion t/events.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ $webkit->wait_for_alert("blurred", 100);
my $httpd = Test::Fake::HTTPD->new;

$httpd->run(sub {
my $req = shift;
return [ 200, [ 'Content-Type', 'text/html' ], [ read_text("$Bin/test/events.html") ] ];
});

Expand Down
2 changes: 1 addition & 1 deletion t/logging.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $webkit = WWW::WebKit2->new(
);

$file = $webkit->write_log('another test');
ok(-d "$dir/logs", 'log folder creted');
ok(-d "$dir/logs", 'log folder created');
is(read_text($file), 'another test', 'log file written');

$webkit->open("$Bin/test/load.html");
Expand Down
3 changes: 1 addition & 2 deletions t/test/keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<title>events</title>
<style>
#big_content { border: 1px solid green; height: 2000px; }
html, body { height: 100%; }
</style>
<script>
Expand All @@ -17,7 +16,7 @@ <h1>Keyboard Header</h1>
<input id="keyboard_input" name="keyboard_input" value="1" />
</form>

<span contenteditable="true" id="editable">Foo Bar Baz<br>01.06.2014 - 31.12.2014</td>
<span contenteditable="true" id="editable">Foo Bar Baz<br>01.06.2014 - 31.12.2014</span>
</div>
</body>
</html>