kiwiroy / mojo-transaction-http-role-mechanize

Role::Tiny based role to mechanize Mojo a little
https://metacpan.org/release/Mojo-Transaction-HTTP-Role-Mechanize
1 stars 2 forks source link

Failing tests for submit value #4

Closed Tekki closed 5 years ago

Tekki commented 5 years ago

Here are some failing tests for #3. I've added a hidden field with name 'p' and a second submit button with the same name. Submit the form without clicking a button should return p = P0, click on the first button p = P1 and click on the second p = P2.

kiwiroy commented 5 years ago

Thanks for this, very helpful. Ignoring these :wink:, p should be an array i.e. p=P0&p=P1 in the two submit cases. I think I have a fix.

Tekki commented 5 years ago

If we make an array the main question is if the order of the parameters is preserved. I'll have to check this against a real world application and probably have no time before the week end. In any case this module already looks much better than HTML::Form! And it's a good example about how to use roles.

kiwiroy commented 5 years ago

I've been looking at this, this and submit spec. Tree order is mentioned there, as is default button, which I also made edits to today. For the submit button value, around val never calls $self->$orig(@args), because the following is different to Mojo::DOM->val. I guess really it should adjust locale/gettext...

https://github.com/kiwiroy/mojo-transaction-http-role-mechanize/blob/d8f853938d2dec085e56f665125921d29287fe07/lib/Mojo/DOM/Role/Form.pm#L58-L63

kiwiroy commented 5 years ago

Quick test at https://www.w3schools.com/html/tryit.asp?filename=tryhtml_elem_datalist with following content seems like order is tree order.

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  <input name=p value=P0 type=hidden />
  <input type="submit" name=p value=P1 />
  <input name=p value=2P type=hidden />
</form>

</body>
</html>