Codeception / lib-innerbrowser

InnerBrowser
MIT License
79 stars 19 forks source link

Support HTML5 form attribute #1

Closed SamMousa closed 4 years ago

SamMousa commented 4 years ago

Fixes https://github.com/Codeception/Codeception/issues/5477

SamMousa commented 4 years ago

Yes I will; but to get an idea of current test status I want to set up coverage first.

Could you got to scrutinizer and add this repository? (I can set up the rest)

https://scrutinizer-ci.com/g/new

DavertMik commented 4 years ago

Done!

SamMousa commented 4 years ago

As it turns out, the current implementation is actually pretty broken.

<html>

<body>
<form id="form1">

    <a href="https://google.nl">
    <button form="invalid" name="abc" >This will link</button>
    </a>
    <a href="https://google.nl">
    <button name="abc" >This will submit</button>
    </a>
</form>
<a href="https://google.nl">
    <button form="form1" name="abcdef" >This will submit</button>
</a>
</body>
</html>

From testing on chrome: Buttons are associated to forms even when nested in an anchor, empty or invalid form attribute disassociate the button from the form; this might lead to it working as a hyperlink.

The codeception implemention will always use an anchor if that is found first.

I will rewrite the implementation of the button.

SamMousa commented 4 years ago

Please review the code carefully.

Note: I do not throw an error when a form attribute contains an invalid ID, it might make sense to throw an error. (I used chrome as a reference, but browsers should be more forgiving than testing frameworks)

Note that an empty form attribute specifically disassociates an input from a containing form, so in such cases the link should be followed:

<form><a href="#"><button form="">Test</button></a></form>