Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for dumping and accessing empty value input elements #312

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -10,6 +10,7 @@ Revision history for WWW::Mechanize
[TESTS]
- Add a test for dump_forms() with multiselect (GH#133) (Julien Fiegehenn)
- Add tests for select multiple (GH#132) (Michael G. Schwern) and (Julien Fiegehenn)
- Add tests for dump_forms() and field() with empty attributes (GH#125) (Julien Fiegehenn)

2.01 2020-09-18 17:51:10Z
- Add rel filter to find_link() (GH#305) (Julien Fiegehenn)
Expand Down
7 changes: 7 additions & 0 deletions t/dump.t
Expand Up @@ -109,6 +109,13 @@ POST http://localhost/ (multipart/form-data) [4th_form_2]
x= (text)
submit=Submit (submit)

POST https://localhost
5a= (hidden readonly)
5b=value (hidden readonly)
5c= (hidden readonly)
5d=foo (hidden readonly)
5e=value (hidden readonly)

EXPECTED
};

Expand Down
4 changes: 4 additions & 0 deletions t/field.html
Expand Up @@ -9,6 +9,10 @@
<INPUT TYPE="radio" NAME="wango" VALUE="wango!">
<INPUT TYPE="radio" NAME="wango" VALUE="wongo!">
<INPUT TYPE="text" NAME="dingo" VALUE="dingo2">
<input type="hidden" name="__no_value">
<input type="hidden" name="__value" value>
<input type="hidden" name="__value_empty" value="">
<input type="hidden" name="__value_full" value="full">
</FORM>
</BODY>
</HTML>
17 changes: 16 additions & 1 deletion t/field.t
Expand Up @@ -2,7 +2,7 @@

use warnings;
use strict;
use Test::More tests => 8;
use Test::More tests => 14;
use URI::file;

BEGIN {
Expand All @@ -28,3 +28,18 @@ is( $mech->value( 'bongo' ), 'bango', 'bongo changed' );
$mech->set_visible( [ radio => 'wongo!' ], 'boingo' );
is( $mech->value( 'wango' ), 'wongo!', 'wango changed' );
is( $mech->value( 'dingo', 2 ), 'boingo', 'dingo changed' );

for my $name (qw/__no_value __value_empty/) {
ok( ! $mech->value( $name ), "$name is empty" ) or diag $mech->field($name);
$mech->field( $name, 'foo');
is( $mech->value( $name ), 'foo', "$name changed" );
}

for my $name (qw/__value/) {
TODO: {
local $TODO = 'HTML::TokeParser does not understand how to parse this and returns a value where it should not have one';
ok( ! $mech->value( $name ), "$name is empty" ) or diag $mech->field($name);
}
$mech->field( $name, 'foo');
is( $mech->value( $name ), 'foo', "$name changed" );
}
8 changes: 8 additions & 0 deletions t/form_with_fields.html
Expand Up @@ -40,4 +40,12 @@
<input type="Submit" name="submit" value="Submit" label="Submit" />
</form>

<form action="https://localhost" method="post">
<input type="hidden" name="5a" />
<input type="hidden" name="5b" value />
<input type="hidden" name="5c" value="" />
<input type="hidden" name="5d" value="foo" />
<input type="hidden" name="5e" value="value" />
</form>

</body>
2 changes: 1 addition & 1 deletion t/google.html
Expand Up @@ -10,5 +10,5 @@
// -->
</script>
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf()><center><table border=0 cellspacing=0 cellpadding=0><tr><td><img src="/images/logo.gif" width=276 height=110 alt="Google"></td></tr></table><br>
<table border=0 cellspacing=0 cellpadding=0><tr><td width=15>&nbsp;</td><td id=0 bgcolor=#3366cc align=center width=95 nowrap><font color=#ffffff size=-1><b>Web</b></font></td><td width=15>&nbsp;</td><td id=1 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8"><font size=-1>Images</font></a></td><td width=15>&nbsp;</td><td id=2 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=2a class=q href="/grphp?hl=en&tab=wg&ie=UTF-8"><font size=-1>Groups</font></a></td><td width=15>&nbsp;</td><td id=3 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=3a class=q href="/dirhp?hl=en&tab=wd&ie=UTF-8"><font size=-1>Directory</font></a></td><td width=15>&nbsp;</td><td id=4 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=4a class=q href="/nwshp?hl=en&tab=wn&ie=UTF-8"><font size=-1>News</font></a></td><td width=15>&nbsp;</td></tr><tr><td colspan=12 bgcolor=#3366cc><img width=1 height=1 alt=""></td></tr></table><br><form action="/target-page" name="bob-the-form"><table cellspacing=0 cellpadding=0><tr><td width=75>&nbsp;</td><td align=center><input type=hidden name=hl value=en><span id=hf></span><input type=hidden name=ie value="ISO-8859-1"><input maxLength=256 size=55 name=q value=""><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'm Feeling Lucky" name=btnI></td><td valign=top nowrap><font size=-2>&nbsp;&#8226;&nbsp;<a href=/advanced_search?hl=en>Advanced&nbsp;Search</a><br>&nbsp;&#8226;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&#8226;&nbsp;<a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><p><font size=-1>Want more from Google? Try these <a href="/tour/services/query.html">expert search tips</a></font><p>
<table border=0 cellspacing=0 cellpadding=0><tr><td width=15>&nbsp;</td><td id=0 bgcolor=#3366cc align=center width=95 nowrap><font color=#ffffff size=-1><b>Web</b></font></td><td width=15>&nbsp;</td><td id=1 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8"><font size=-1>Images</font></a></td><td width=15>&nbsp;</td><td id=2 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=2a class=q href="/grphp?hl=en&tab=wg&ie=UTF-8"><font size=-1>Groups</font></a></td><td width=15>&nbsp;</td><td id=3 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=3a class=q href="/dirhp?hl=en&tab=wd&ie=UTF-8"><font size=-1>Directory</font></a></td><td width=15>&nbsp;</td><td id=4 bgcolor=#efefef align=center width=95 nowrap onClick="" style=cursor:pointer;cursor:hand;><a id=4a class=q href="/nwshp?hl=en&tab=wn&ie=UTF-8"><font size=-1>News</font></a></td><td width=15>&nbsp;</td></tr><tr><td colspan=12 bgcolor=#3366cc><img width=1 height=1 alt=""></td></tr></table><br><form action="/target-page" name="bob-the-form"><table cellspacing=0 cellpadding=0><tr><td width=75>&nbsp;</td><td align=center><input type=hidden name=hl value=en><span id=hf></span><input type=hidden name=ie value="ISO-8859-1"><input type=hidden name=notgoogle value=""><input maxLength=256 size=55 name=q value=""><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'm Feeling Lucky" name=btnI></td><td valign=top nowrap><font size=-2>&nbsp;&#8226;&nbsp;<a href=/advanced_search?hl=en>Advanced&nbsp;Search</a><br>&nbsp;&#8226;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&#8226;&nbsp;<a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><p><font size=-1>Want more from Google? Try these <a href="/tour/services/query.html">expert search tips</a></font><p>
<br><font size=-1><a href="/ads/">Advertise&nbsp;with&nbsp;Us</a> - <a href="/services/">Business&nbsp;Solutions</a> - <a href="/options/">Services&nbsp;&amp;&nbsp;Tools</a> - <a href=/about.html>Jobs,&nbsp;Press,&nbsp;&amp;&nbsp;Help</a></font><p><font size=-2>&copy;2003 Google - Searching 3,083,324,652 web pages</font></p></center></body></html>
2 changes: 2 additions & 0 deletions t/mech-dump/mech-dump.t
Expand Up @@ -35,6 +35,7 @@ if ( $LWP::VERSION < 5.800 ) {
GET file:/target-page [bob-the-form]
hl=en (hidden)
ie=ISO-8859-1 (hidden)
notgoogle= (hidden readonly)
q=
btnG=Google Search (submit)
btnI=I'm Feeling Lucky (submit)
Expand Down Expand Up @@ -62,6 +63,7 @@ EOF
GET file:/target-page [bob-the-form]
hl=en (hidden readonly)
ie=ISO-8859-1 (hidden readonly)
notgoogle= (hidden readonly)
q= (text)
btnG=Google Search (submit)
btnI=I'm Feeling Lucky (submit)
Expand Down