Skip to content

Commit

Permalink
Fix see when source code contains <= JS operator (#4510)
Browse files Browse the repository at this point in the history
* Added new test case

* Remove script tags before using strip_tags
  • Loading branch information
tobias-kuendig authored and Naktibalda committed Oct 28, 2017
1 parent 3150e64 commit d64f8dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Codeception/Lib/InnerBrowser.php
Expand Up @@ -1888,6 +1888,10 @@ protected function setCookiesFromOptions()
protected function getNormalizedResponseContent()
{
$content = $this->_getResponseContent();
// Since strip_tags has problems with JS code that contains
// an <= operator the script tags have to be removed manually first.
$content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);

$content = strip_tags($content);
$content = html_entity_decode($content, ENT_QUOTES);
$content = str_replace("\n", ' ', $content);
Expand Down
9 changes: 9 additions & 0 deletions tests/data/app/view/info.php
Expand Up @@ -44,5 +44,14 @@
<a id="third-link">Third</a>
</div>

<script>
var a = 2;
var b = 3;
if (a <= b) {
console.log('a is less than b!');
}
</script>
<p>Text behind JS comparision</p>

</body>
</html>
8 changes: 8 additions & 0 deletions tests/unit/Codeception/Module/PhpBrowserTest.php
Expand Up @@ -71,6 +71,14 @@ public function testLinksWithNonLatin()
$this->module->click('Ссылочка');
}

/**
* @see https://github.com/Codeception/Codeception/issues/4509
*/
public function testSeeTextAfterJSComparisionOperator()
{
$this->module->amOnPage('/info');
$this->module->see('Text behind JS comparision');
}

public function testSetMultipleCookies()
{
Expand Down

0 comments on commit d64f8dd

Please sign in to comment.