Commit 0cc8ee98 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: add more cases to inBodyIM

Don't set framesetOK to false for hidden input elements.

Handle <param>, <source>, <track>, <textarea>, <iframe>, <noembed>,
and <noscript>

Pass 7 additional tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6094045
parent cad48044
...@@ -643,7 +643,7 @@ func inBodyIM(p *parser) bool { ...@@ -643,7 +643,7 @@ func inBodyIM(p *parser) bool {
case TextToken: case TextToken:
d := p.tok.Data d := p.tok.Data
switch n := p.oe.top(); n.Data { switch n := p.oe.top(); n.Data {
case "pre", "listing", "textarea": case "pre", "listing":
if len(n.Child) == 0 { if len(n.Child) == 0 {
// Ignore a newline at the start of a <pre> block. // Ignore a newline at the start of a <pre> block.
if d != "" && d[0] == '\r' { if d != "" && d[0] == '\r' {
...@@ -779,12 +779,6 @@ func inBodyIM(p *parser) bool { ...@@ -779,12 +779,6 @@ func inBodyIM(p *parser) bool {
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.afe = append(p.afe, &scopeMarker) p.afe = append(p.afe, &scopeMarker)
p.framesetOK = false p.framesetOK = false
case "area", "br", "embed", "img", "input", "keygen", "wbr":
p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr)
p.oe.pop()
p.acknowledgeSelfClosingTag()
p.framesetOK = false
case "table": case "table":
if !p.quirks { if !p.quirks {
p.popUntil(buttonScope, "p") p.popUntil(buttonScope, "p")
...@@ -793,6 +787,26 @@ func inBodyIM(p *parser) bool { ...@@ -793,6 +787,26 @@ func inBodyIM(p *parser) bool {
p.framesetOK = false p.framesetOK = false
p.im = inTableIM p.im = inTableIM
return true return true
case "area", "br", "embed", "img", "input", "keygen", "wbr":
p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr)
p.oe.pop()
p.acknowledgeSelfClosingTag()
if p.tok.Data == "input" {
for _, a := range p.tok.Attr {
if a.Key == "type" {
if strings.ToLower(a.Val) == "hidden" {
// Skip setting framesetOK = false
return true
}
}
}
}
p.framesetOK = false
case "param", "source", "track":
p.addElement(p.tok.Data, p.tok.Attr)
p.oe.pop()
p.acknowledgeSelfClosingTag()
case "hr": case "hr":
p.popUntil(buttonScope, "p") p.popUntil(buttonScope, "p")
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
...@@ -852,11 +866,27 @@ func inBodyIM(p *parser) bool { ...@@ -852,11 +866,27 @@ func inBodyIM(p *parser) bool {
p.oe.pop() p.oe.pop()
p.oe.pop() p.oe.pop()
p.form = nil p.form = nil
case "textarea":
p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM()
p.framesetOK = false
p.im = textIM
case "xmp": case "xmp":
p.popUntil(buttonScope, "p") p.popUntil(buttonScope, "p")
p.reconstructActiveFormattingElements() p.reconstructActiveFormattingElements()
p.framesetOK = false p.framesetOK = false
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM()
p.im = textIM
case "iframe":
p.framesetOK = false
p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM()
p.im = textIM
case "noembed", "noscript":
p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM()
p.im = textIM
case "math", "svg": case "math", "svg":
p.reconstructActiveFormattingElements() p.reconstructActiveFormattingElements()
if p.tok.Data == "math" { if p.tok.Data == "math" {
...@@ -1074,7 +1104,20 @@ func textIM(p *parser) bool { ...@@ -1074,7 +1104,20 @@ func textIM(p *parser) bool {
case ErrorToken: case ErrorToken:
p.oe.pop() p.oe.pop()
case TextToken: case TextToken:
p.addText(p.tok.Data) d := p.tok.Data
if n := p.oe.top(); n.Data == "textarea" && len(n.Child) == 0 {
// Ignore a newline at the start of a <textarea> block.
if d != "" && d[0] == '\r' {
d = d[1:]
}
if d != "" && d[0] == '\n' {
d = d[1:]
}
}
if d == "" {
return true
}
p.addText(d)
return true return true
case EndTagToken: case EndTagToken:
p.oe.pop() p.oe.pop()
......
FAIL "<input type=\"hidden\"><frameset>" PASS "<input type=\"hidden\"><frameset>"
PASS "<!DOCTYPE html><table><caption><svg>foo</table>bar" PASS "<!DOCTYPE html><table><caption><svg>foo</table>bar"
...@@ -66,9 +66,9 @@ PASS "<!doctype html><input><frameset>" ...@@ -66,9 +66,9 @@ PASS "<!doctype html><input><frameset>"
PASS "<!doctype html><keygen><frameset>" PASS "<!doctype html><keygen><frameset>"
PASS "<!doctype html><wbr><frameset>" PASS "<!doctype html><wbr><frameset>"
PASS "<!doctype html><hr><frameset>" PASS "<!doctype html><hr><frameset>"
FAIL "<!doctype html><textarea></textarea><frameset>" PASS "<!doctype html><textarea></textarea><frameset>"
PASS "<!doctype html><xmp></xmp><frameset>" PASS "<!doctype html><xmp></xmp><frameset>"
FAIL "<!doctype html><iframe></iframe><frameset>" PASS "<!doctype html><iframe></iframe><frameset>"
PASS "<!doctype html><select></select><frameset>" PASS "<!doctype html><select></select><frameset>"
PASS "<!doctype html><svg></svg><frameset><frame>" PASS "<!doctype html><svg></svg><frameset><frame>"
PASS "<!doctype html><math></math><frameset><frame>" PASS "<!doctype html><math></math><frameset><frame>"
......
...@@ -14,7 +14,7 @@ PASS "<!DOCTYPE html><body><input>A" ...@@ -14,7 +14,7 @@ PASS "<!DOCTYPE html><body><input>A"
PASS "<!DOCTYPE html><body><keygen>A" PASS "<!DOCTYPE html><body><keygen>A"
PASS "<!DOCTYPE html><body><link>A" PASS "<!DOCTYPE html><body><link>A"
PASS "<!DOCTYPE html><body><meta>A" PASS "<!DOCTYPE html><body><meta>A"
FAIL "<!DOCTYPE html><body><param>A" PASS "<!DOCTYPE html><body><param>A"
FAIL "<!DOCTYPE html><body><source>A" PASS "<!DOCTYPE html><body><source>A"
FAIL "<!DOCTYPE html><body><track>A" PASS "<!DOCTYPE html><body><track>A"
PASS "<!DOCTYPE html><body><wbr>A" PASS "<!DOCTYPE html><body><wbr>A"
...@@ -45,5 +45,5 @@ PASS "<svg><em><desc></em>" ...@@ -45,5 +45,5 @@ PASS "<svg><em><desc></em>"
PASS "<table><tr><td><svg><desc><td></desc><circle>" PASS "<table><tr><td><svg><desc><td></desc><circle>"
PASS "<svg><tfoot></mi><td>" PASS "<svg><tfoot></mi><td>"
PASS "<math><mrow><mrow><mn>1</mn></mrow><mi>a</mi></mrow></math>" PASS "<math><mrow><mrow><mn>1</mn></mrow><mi>a</mi></mrow></math>"
FAIL "<!doctype html><input type=\"hidden\"><frameset>" PASS "<!doctype html><input type=\"hidden\"><frameset>"
PASS "<!doctype html><input type=\"button\"><frameset>" PASS "<!doctype html><input type=\"button\"><frameset>"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment