diff options
Diffstat (limited to 'libgo/go/html/parse_test.go')
-rw-r--r-- | libgo/go/html/parse_test.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libgo/go/html/parse_test.go b/libgo/go/html/parse_test.go index b0ddd92..b9572fa 100644 --- a/libgo/go/html/parse_test.go +++ b/libgo/go/html/parse_test.go @@ -132,7 +132,7 @@ func TestParser(t *testing.T) { rc := make(chan io.Reader) go readDat(filename, rc) // TODO(nigeltao): Process all test cases, not just a subset. - for i := 0; i < 34; i++ { + for i := 0; i < 80; i++ { // Parse the #data section. b, err := ioutil.ReadAll(<-rc) if err != nil { @@ -160,14 +160,10 @@ func TestParser(t *testing.T) { t.Errorf("%s test #%d %q, got vs want:\n----\n%s----\n%s----", filename, i, text, got, want) continue } - // Check that rendering and re-parsing results in an identical tree. - if filename == "tests1.dat" && i == 30 { - // Test 30 in tests1.dat is such messed-up markup that a correct parse - // results in a non-conforming tree (one <a> element nested inside another). - // Therefore when it is rendered and re-parsed, it isn't the same. - // So we skip rendering on that test. + if renderTestBlacklist[text] { continue } + // Check that rendering and re-parsing results in an identical tree. pr, pw := io.Pipe() go func() { pw.CloseWithError(Render(pw, doc)) @@ -187,3 +183,15 @@ func TestParser(t *testing.T) { } } } + +// Some test input result in parse trees are not 'well-formed' despite +// following the HTML5 recovery algorithms. Rendering and re-parsing such a +// tree will not result in an exact clone of that tree. We blacklist such +// inputs from the render test. +var renderTestBlacklist = map[string]bool{ + // The second <a> will be reparented to the first <table>'s parent. This + // results in an <a> whose parent is an <a>, which is not 'well-formed'. + `<a><table><td><a><table></table><a></tr><a></table><b>X</b>C<a>Y`: true, + // The second <a> will be reparented, similar to the case above. + `<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true, +} |