diff options
author | Matt Butcher <[email protected]> | 2013-04-24 22:54:20 -0500 |
---|---|---|
committer | Matt Butcher <[email protected]> | 2013-04-24 22:54:20 -0500 |
commit | be7f40d38223cf6cf4aa1ce180de9e3bd36672c5 (patch) | |
tree | 15815b0298c52c1f496bb33612922ba8bb780e54 /test | |
parent | e6e65eccd8d37376a01f5ec134dd3e20e0e9dd49 (diff) |
MAJOR changes to the DOMTreeBuilder.
This now supports most of the tree building. It has limited support for
insertion modes, as well as some syntax correction.
Diffstat (limited to 'test')
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index a901238..562b9d5 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -76,8 +76,34 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('a', $body2->getAttribute('id')); } + public function testMissingHtmlTag() { + $html = "<!DOCTYPE html><title>test</title>"; + $doc = $this->parse($html); + + $this->assertEquals('html', $doc->documentElement->tagName); + $this->assertEquals('title', $doc->documentElement->childNodes->item(0)->tagName); + } + public function testComment() { - $this->markTestIncomplete("Incomplete."); + $html = '<html><!--Hello World.--></html>'; + + $doc = $this->parse($html); + + $comment = $doc->documentElement->childNodes->item(0); + $this->assertEquals(XML_COMMENT_NODE, $comment->nodeType); + $this->assertEquals("Hello World.", $comment->data); + + + $html = '<!--Hello World.--><html></html>'; + $doc = $this->parse($html); + + $comment = $doc->childNodes->item(1); + $this->assertEquals(XML_COMMENT_NODE, $comment->nodeType); + $this->assertEquals("Hello World.", $comment->data); + + $comment = $doc->childNodes->item(2); + $this->assertEquals(XML_ELEMENT_NODE, $comment->nodeType); + $this->assertEquals("html", $comment->tagName); } public function testCDATA() { @@ -95,4 +121,13 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { public function testProcessingInstruction() { $this->markTestIncomplete("Incomplete."); } + + public function testAutocloseP() { + $html = "<!DOCTYPE html><html><body><p><figure></body></html>"; + $doc = $this->parse($html); + + $p = $doc->getElementsByTagName('p')->item(0); + $this->assertEquals(0, $p->childNodes->length); + $this->assertEquals('figure', $p->nextSibling->tagName); + } } |