| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::WebTest::Plugin::Sticky; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
73557
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
HTTP::WebTest::Plugin::Sticky - Propagate hidden and text form fields |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.03 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
plugins = ( ::Sticky ) |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
test_name = Some test |
|
23
|
|
|
|
|
|
|
sticky = yes |
|
24
|
|
|
|
|
|
|
click_button = Next |
|
25
|
|
|
|
|
|
|
params = ( |
|
26
|
|
|
|
|
|
|
name => 'This is a new text field' |
|
27
|
|
|
|
|
|
|
) |
|
28
|
|
|
|
|
|
|
end_test |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This plugin for the HTTP::WebTest module let you post a form that |
|
33
|
|
|
|
|
|
|
includes all the inputs from the page, including hidden ones. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Also you can add new inputs using the "params" hash. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
In case of inputs of type "checkbox", they are included only if |
|
38
|
|
|
|
|
|
|
they have the "checked" property. In other case, you must set it |
|
39
|
|
|
|
|
|
|
on purpose using the normal "params" hash. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 TEST PARAMETERS |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 sticky |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Allow/disallows the fields propagation. Values allowed: yes / no. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
569
|
use HTML::TokeParser; |
|
|
1
|
|
|
|
|
12036
|
|
|
|
1
|
|
|
|
|
43
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
11
|
use base qw(HTTP::WebTest::Plugin); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
818
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub param_types { |
|
55
|
0
|
|
|
0
|
1
|
|
return 'sticky yesno |
|
56
|
|
|
|
|
|
|
params hashlist'; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub prepare_request { |
|
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
|
$self->validate_params(qw(sticky params)); |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $request = $self->webtest->current_request; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $prev_test_num = $self->webtest->current_test_num - 1; |
|
66
|
0
|
0
|
|
|
|
|
return if $prev_test_num < 0; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $response = $self->webtest->tests->[$prev_test_num]->response; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
return unless defined $response; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
return unless $response->content_type eq 'text/html'; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $sticky = $self->test_param('sticky'); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
return unless defined($sticky); |
|
77
|
0
|
0
|
|
|
|
|
return unless $sticky eq 'yes'; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $params = $self->test_param('params'); |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $content = $response->content; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my %inputs = (); |
|
84
|
0
|
|
|
|
|
|
my $parser = HTML::TokeParser->new(\$content); |
|
85
|
0
|
|
|
|
|
|
while(my $token = $parser->get_tag('input')) { |
|
86
|
0
|
|
|
|
|
|
my $type = $token->[1]{type}; |
|
87
|
0
|
0
|
|
|
|
|
next unless defined $type; |
|
88
|
0
|
|
|
|
|
|
my $name = $token->[1]{name}; |
|
89
|
0
|
0
|
|
|
|
|
next unless defined $name; |
|
90
|
0
|
|
|
|
|
|
my $value = $token->[1]{value}; |
|
91
|
0
|
0
|
|
|
|
|
next unless defined $value; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
0
|
0
|
|
|
|
next if (lc($type) eq 'checkbox') and not defined($token->[1]{checked}); |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$inputs{$name} = $value; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
0
|
|
|
|
|
if(defined $params) { |
|
98
|
0
|
0
|
|
|
|
|
my %params = ref($params) eq "ARRAY" ? @$params : %$params; |
|
99
|
0
|
|
|
|
|
|
for my $key (keys(%params)) { |
|
100
|
0
|
|
|
|
|
|
$inputs{$key} = $params{$key}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
0
|
|
|
|
|
|
my @inputs = %inputs; |
|
104
|
0
|
|
|
|
|
|
$request->params(\@inputs); |
|
105
|
0
|
|
|
|
|
|
return []; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Hugo Salgado H., C<< >> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
118
|
|
|
|
|
|
|
C<~huguei/perl-HTTP-WebTest-Plugin-Sticky@todo.sr.ht>, or through the web interface at |
|
119
|
|
|
|
|
|
|
L. |
|
120
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
121
|
|
|
|
|
|
|
your bug as I make changes. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SUPPORT |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
perldoc HTTP::WebTest::Plugin::Sticky |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
You can also look for general information at: |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
perldoc HTTP::WebTest |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * sourcehut's request tracker |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * Search CPAN |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The code was based in a lost posting on the webtest mailing list. Thanks |
|
152
|
|
|
|
|
|
|
to whoever was responsible for that. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2006 Hugo Salgado H., all rights reserved. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
159
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; # End of HTTP::WebTest::Plugin::Sticky |
|
172
|
|
|
|
|
|
|
|