Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294586

Browser tests: Plain page text contains CSS styles and JS settings

$
0
0

Problem/Motivation

When invoking $this->getTextContent() or $this->assertSession()->pageTextContains() on BrowserTestBase then the plain text page content is not correct. The text content of <style> and <script> tags is included in the page text, but it should only contain text that a human can see on the page.

The problem is that Mink just uses PHP's DOMDocument extension to get the nodeValue from the document, which extracts the text content of all tags regardless of their meaning.

Proposed resolution

Override Mink's Session class to return our own DocumentElement when the page content is requested. That way we can filter out styles and scripts when the text version of a page is requested. This also fixes the problem for assertSession()->pageTextContains() and getTextContent() in one place and we can avoid overriding the Mink driver class.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.


Viewing all articles
Browse latest Browse all 294586

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>