Permalink
Browse files

Fixed textarea glitch with Tidy parser. Tidy parser now default

  • Loading branch information...
1 parent 6b8d02b commit 6b4bc40cf80fbac7fe964922e401a25fdee8a5ea lastcraft committed Dec 13, 2009
Showing with 32 additions and 9 deletions.
  1. +2 −2 browser.php
  2. +7 −1 test/acceptance_test.php
  3. +17 −1 test/parsing_test.php
  4. +6 −5 tidy_parser.php
View
@@ -19,8 +19,8 @@
require_once(dirname(__FILE__) . '/frames.php');
require_once(dirname(__FILE__) . '/user_agent.php');
if (! SimpleTest::getParsers()) {
- //SimpleTest::setParsers(array(new SimpleTidyPageBuilder(), new SimplePHPPageBuilder()));
- SimpleTest::setParsers(array(new SimplePHPPageBuilder()));
+ SimpleTest::setParsers(array(new SimpleTidyPageBuilder(), new SimplePHPPageBuilder()));
+ //SimpleTest::setParsers(array(new SimplePHPPageBuilder()));
}
/**#@-*/
@@ -989,7 +989,13 @@ function testSettingVariousBlanksInFields() {
function testDefaultValueOfTextareaHasNewlinesAndWhitespacePreserved() {
$this->get($this->samples() . 'form_with_false_defaults.html');
- $this->assertField('Text area C', " ");
+ $this->assertField('Text area C', ' ');
+ }
+
+ function chars($t) {
+ for ($i = 0; $i < strlen($t); $i++) {
+ print "[$t[$i]]";
+ }
}
function testSubmissionOfBlankFields() {
View
@@ -426,7 +426,23 @@ function testNewlinesPreservedInTextArea() {
function testWhitespacePreservedInTextArea() {
$raw = '<form><textarea name="a"> </textarea></form>';
$page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), " ");
+ $this->assertEqual($page->getField(new SimpleByName('a')), ' ');
+ }
+
+ function testComplexWhitespaceInTextArea() {
+ $raw = "<html>\n" .
+ " <head><title></title></head>\n" .
+ " <body>\n" .
+ " <form>\n".
+ " <label>Text area C\n" .
+ " <textarea name='c'>\n" .
+ " </textarea>\n" .
+ " </label>\n" .
+ " </form>\n" .
+ " </body>\n" .
+ "</html>";
+ $page = $this->whenVisiting('http://host', $raw);
+ $this->assertEqual($page->getField(new SimpleByName('c')), " ");
}
function testSettingTextArea() {
View
@@ -79,20 +79,21 @@ private function stripGuards($html) {
/**
* HTML tidy strips out empty tags such as <option> which we
- * need to preserve. This method inserts an additional tag.
+ * need to preserve. This method inserts an additional marker.
* @param string The raw html.
* @return string The html with guards inserted.
*/
private function insertEmptyTagGuards($html) {
- return preg_replace('#<(option|textarea)([^>]*)>(\s*)</(option|textarea)>#',
+ return preg_replace('#<(option|textarea)([^>]*)>(\s*)</(option|textarea)>#is',
'<\1\2>___EMPTY___\3</\4>',
$html);
}
/**
* HTML tidy strips out empty tags such as <option> which we
- * need to preserve. This method strips additional tags
- * inserted by SimpleTest to the tidy output.
+ * need to preserve. This method strips additional markers
+ * inserted by SimpleTest to the tidy output used to make the
+ * tags non-empty. This ensures their preservation.
* @param string The raw html.
* @return string The html with guards removed.
*/
@@ -108,7 +109,7 @@ private function stripEmptyTagGuards($html) {
* @return string The html with guards inserted.
*/
private function insertTextareaSimpleWhitespaceGuards($html) {
- return preg_replace_callback('#<textarea([^>]*)>(.*?)</textarea>#',
+ return preg_replace_callback('#<textarea([^>]*)>(.*?)</textarea>#is',
array($this, 'insertWhitespaceGuards'),
$html);
}

0 comments on commit 6b4bc40

Please sign in to comment.