[Jifty-commit] r1855 - in jifty/trunk: lib/Jifty/Test/WWW

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Aug 24 02:11:07 EDT 2006


Author: srl
Date: Thu Aug 24 02:10:55 2006
New Revision: 1855

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm

Log:
 r17966 at kootenai:  srl | 2006-08-24 00:40:02 -0400
 moniker_for and action_form now behave more cleanly with forms which
 have no non-continuation fields other than their submit buttons.


Modified: jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	(original)
+++ jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	Thu Aug 24 02:10:55 2006
@@ -88,6 +88,17 @@
         return $1;
       }
     }
+    # if we've gotten to this point, there were no hidden fields with a moniker,
+    # possibly a form with only its continuation-marking hidden field.
+    # Fall back to a submit field with similar attributes.
+    for my $input ($f->inputs) {
+	if ($input->type eq "submit" and $input->name =~ /$action/
+	    and $input->name =~ /J:ACTIONS=([^|]+)|/ ) {
+	  $input->name =~ /J:ACTIONS=(\w+S\d+)|/;
+	  my $moniker = $1;
+	  return $moniker;
+      }
+    }
   }
   return undef;
 }
@@ -168,6 +179,22 @@
         $self->form_number($i); #select it, for $mech->submit etc
         return $form;
     } 
+
+    # A fallback for forms that don't have any named fields except their
+    # submit button. Could stand to be refactored.
+    $i = 0;
+    for my $form ($self->forms) {
+        no warnings 'uninitialized';
+
+        $i++;
+        next unless first {   $_->name =~ /J:A-(?:\d+-)?$moniker/
+                           && $_->type eq "submit" }
+                        $form->inputs;
+        next if grep {not $form->find_input("J:A:F-$_-$moniker")} @fields;
+
+        $self->form_number($i); #select it, for $mech->submit etc
+        return $form;
+    } 
     return;
 } 
 
@@ -398,6 +425,7 @@
     }
 } 
 
+
 =head2 session
 
 Returns the server-side L<Jifty::Web::Session> object associated with


More information about the Jifty-commit mailing list