This is just a quick test that adds a link field through the browser and creates a node with this link.

Comments

pkiraly’s picture

StatusFileSize
new4.16 KB

Appending the test file with some more test cases

chx’s picture

Browser based tests are a lot easier to write and port to D7 .

jcfiala’s picture

This is really cool, but I'm noticing a problem with it - the xpath throws warnings when it hits paths like //a[@href="http://example.com/s549952LRefyAJT" and text()="s549952M5g5RZzD<script>alert("hi");</script>"]. I think this is because text() is supposed to be searching for *only* text nodes, and by putting the <script> tag inside of the text, it no longer qualifies as a text node.

XML is hard. :)

I'm working on trying to come up with a method to do the tests you want to do, but stop errors from popping up. Well, not errors, warnings.

jcfiala’s picture

Hm. Well, you seem to really need that to fail, because you're testing to see if nothing is found if the link type isn't good. So, I put libxml_use_internal_errors(TRUE) before your call to $this->xpath(), and libxml_use_internal_errors(FALSE) afterwards. That way the warnings we don't want to see, but expect, don't cause us any trouble.

I'm going to include this into the project. Thanks!

jcfiala’s picture

Status: Needs review » Fixed

And, might as well set it as fixed. Thanks for the help!

chx’s picture

Title: Link create from browser test » simpletest xpath error handling
Project: Link » Drupal core
Version: 6.x-2.x-dev » 7.x-dev
Component: Code » simpletest.module
Category: task » bug
Status: Fixed » Needs review
StatusFileSize
new1.05 KB

Status: Needs review » Needs work

The last submitted patch, libxml_use_internal_errors.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
boombatower’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

dries’s picture

This patch works for me, although it could use a code comment. I had to look up libxml_use_internal_errors() to understand what the patch does, and then had to know Drupal to understand why we're not using a custom error handler. So, can we add a little bit of documentation to describe this test and its implementation? Thanks!

elijah lynn’s picture

#8: libxml_use_internal_errors.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, libxml_use_internal_errors.patch, failed testing.

chx’s picture

Assigned: chx » Unassigned
Issue summary: View changes

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.