From f85f7cf8c109bdec720eb68c15c04f31b565a873 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 30 Mar 2009 05:35:35 +0000 Subject: #349237 by c960657: Fix assertTitle()'s encoding of HTML attributes (with tests). --- modules/node/node.test | 2 ++ modules/simpletest/drupal_web_test_case.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/node/node.test b/modules/node/node.test index ab7301a3a..bbc91b5ef 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -501,6 +501,8 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase { $node = $this->drupalCreateNode($edit); $this->drupalGet('node/' . $node->nid); + // assertTitle() decodes HTML-entities inside the element. + $this->assertTitle($edit['title'] . ' | Drupal', t('Title is diplayed when viewing a node.')); $this->assertNoRaw($xss, t('Harmful tags are escaped when viewing a node.')); $this->drupalGet('node/' . $node->nid . '/edit'); diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index b865d8659..8004b40dd 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1821,7 +1821,7 @@ class DrupalWebTestCase { * TRUE on pass, FALSE on fail. */ protected function assertTitle($title, $message, $group = 'Other') { - return $this->assertTrue($this->xpath('//title[text()="' . $title . '"]'), $message, $group); + return $this->assertEqual(current($this->xpath('//title')), $title, $message, $group); } /** @@ -1837,7 +1837,7 @@ class DrupalWebTestCase { * TRUE on pass, FALSE on fail. */ protected function assertNoTitle($title, $message, $group = 'Other') { - return $this->assertFalse($this->xpath('//title[text()="' . $title . '"]'), $message, $group); + return $this->assertNotEqual(current($this->xpath('//title')), $title, $message, $group); } /** -- cgit v1.2.3