WebKit/Client/Element.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 45 CC 1 SCAR 6.9
CC
1
Cov
0%
_new
2.0
handle
2.0
release
2.0
CRAP 2.0
1 package EV::WebKit::Client::Element;
2 use v5.10;
3 use strict;
4 use warnings;
5  
6 our $VERSION = '0.05';
7  
8 # A remote element. The real EV::WebKit::Element lives in the browser process;
9 # this is a handle to it, and the same methods, each one an el.* request.
10 #
11 # The handle is only valid until the page navigates: the browser's element
12 # registry stamps every handle with the document's epoch, so a handle from a page
13 # that has gone away answers 'stale element' rather than quietly reading the
14 # wrong node. The server frees them at the same moment, for the same reason.
15  
16 sub _new { bless { c => $_[1], h => $_[2] }, $_[0] }
17  
18 sub handle { $_[0]{h} }
19  
20 # text/html/value/tag/attr/prop/is_visible/click/focus/type/clear/submit all take
21 # (@args, $cb?) and return a plain value. find/find_all return handles, so they
22 # are generated separately below.
23 for my $m (qw(text html value tag attr prop is_visible click focus type clear submit
24 scroll_into_view hover box check uncheck select_option send_keys)) {
25 no strict 'refs';
26 *{__PACKAGE__ . "::$m"} = sub {
27 my $self = shift;
28 return $self->{c}->_call("el.$m", [@_], $self->{h});
29 };
30 }
31  
32 for my $m (qw(find find_all)) {
33 no strict 'refs';
34 *{__PACKAGE__ . "::$m"} = sub {
35 my $self = shift;
36 return $self->{c}->_call_el("el.$m", [@_], $self->{h});
37 };
38 }
39  
40 sub release {
41 my $self = shift;
42 # [@_], like every generated method above: passing [] discarded the caller's
43 # trailing callback before _cb could find it, so in ev mode -- which requires
44 # one -- every spelling of release croaked, and from inside another callback
45 # that croak is only a warn while the handle is never freed.
46 return $self->{c}->_call('el.release', [@_], $self->{h});
47 }
48  
49 1;
50  
51 __END__