Skip to content

Commit 008ff26

Browse files
committed
Move the serializer testdata to html5lib-python as impl specific
1 parent 84e8802 commit 008ff26

File tree

7 files changed

+1271
-3
lines changed

7 files changed

+1271
-3
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{"tests": [
2+
3+
{"description": "proper attribute value escaping",
4+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "test \"with\" ""}]]],
5+
"expected": ["<span title='test \"with\" &amp;quot;'>"]
6+
},
7+
8+
{"description": "proper attribute value non-quoting",
9+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo"}]]],
10+
"expected": ["<span title=foo>"],
11+
"xhtml": ["<span title=\"foo\">"]
12+
},
13+
14+
{"description": "proper attribute value non-quoting (with <)",
15+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo<bar"}]]],
16+
"expected": ["<span title=foo<bar>"],
17+
"xhtml": ["<span title=\"foo&lt;bar\">"]
18+
},
19+
20+
{"description": "proper attribute value quoting (with =)",
21+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo=bar"}]]],
22+
"expected": ["<span title=\"foo=bar\">"]
23+
},
24+
25+
{"description": "proper attribute value quoting (with >)",
26+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo>bar"}]]],
27+
"expected": ["<span title=\"foo>bar\">"]
28+
},
29+
30+
{"description": "proper attribute value quoting (with \")",
31+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\"bar"}]]],
32+
"expected": ["<span title='foo\"bar'>"]
33+
},
34+
35+
{"description": "proper attribute value quoting (with ')",
36+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo'bar"}]]],
37+
"expected": ["<span title=\"foo'bar\">"]
38+
},
39+
40+
{"description": "proper attribute value quoting (with both \" and ')",
41+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo'bar\"baz"}]]],
42+
"expected": ["<span title=\"foo'bar&quot;baz\">"]
43+
},
44+
45+
{"description": "proper attribute value quoting (with space)",
46+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo bar"}]]],
47+
"expected": ["<span title=\"foo bar\">"]
48+
},
49+
50+
{"description": "proper attribute value quoting (with tab)",
51+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\tbar"}]]],
52+
"expected": ["<span title=\"foo\tbar\">"]
53+
},
54+
55+
{"description": "proper attribute value quoting (with LF)",
56+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\nbar"}]]],
57+
"expected": ["<span title=\"foo\nbar\">"]
58+
},
59+
60+
{"description": "proper attribute value quoting (with CR)",
61+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\rbar"}]]],
62+
"expected": ["<span title=\"foo\rbar\">"]
63+
},
64+
65+
{"description": "proper attribute value non-quoting (with linetab)",
66+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\u000Bbar"}]]],
67+
"expected": ["<span title=foo\u000Bbar>"],
68+
"xhtml": ["<span title=\"foo\u000Bbar\">"]
69+
},
70+
71+
{"description": "proper attribute value quoting (with form feed)",
72+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "span", [{"namespace": null, "name": "title", "value": "foo\u000Cbar"}]]],
73+
"expected": ["<span title=\"foo\u000Cbar\">"]
74+
},
75+
76+
{"description": "void element (as EmptyTag token)",
77+
"input": [["EmptyTag", "img", {}]],
78+
"expected": ["<img>"],
79+
"xhtml": ["<img />"]
80+
},
81+
82+
{"description": "void element (as StartTag token)",
83+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "img", {}]],
84+
"expected": ["<img>"],
85+
"xhtml": ["<img />"]
86+
},
87+
88+
{"description": "doctype in error",
89+
"input": [["Doctype", "foo"]],
90+
"expected": ["<!DOCTYPE foo>"]
91+
},
92+
93+
{"description": "character data",
94+
"options": {"encoding":"utf-8"},
95+
"input": [["Characters", "a<b>c&d"]],
96+
"expected": ["a&lt;b&gt;c&amp;d"]
97+
},
98+
99+
{"description": "rcdata",
100+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "script", {}], ["Characters", "a<b>c&d"]],
101+
"expected": ["<script>a<b>c&d"],
102+
"xhtml": ["<script>a&lt;b&gt;c&amp;d"]
103+
},
104+
105+
{"description": "doctype",
106+
"input": [["Doctype", "HTML"]],
107+
"expected": ["<!DOCTYPE HTML>"]
108+
},
109+
110+
{"description": "HTML 4.01 DOCTYPE",
111+
"input": [["Doctype", "HTML", "-//W3C//DTD HTML 4.01//EN", "http://www.w3.org/TR/html4/strict.dtd"]],
112+
"expected": ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"]
113+
},
114+
115+
{"description": "HTML 4.01 DOCTYPE without system identifer",
116+
"input": [["Doctype", "HTML", "-//W3C//DTD HTML 4.01//EN"]],
117+
"expected": ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"]
118+
},
119+
120+
{"description": "IBM DOCTYPE without public identifer",
121+
"input": [["Doctype", "html", "", "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"]],
122+
"expected": ["<!DOCTYPE html SYSTEM \"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd\">"]
123+
}
124+
125+
]}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{"tests": [
2+
3+
{"description": "no encoding",
4+
"options": {"inject_meta_charset": true},
5+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
6+
"expected": [""],
7+
"xhtml": ["<head></head>"]
8+
},
9+
10+
{"description": "empytag head",
11+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
12+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
13+
"expected": ["<meta charset=utf-8>"],
14+
"xhtml": ["<head><meta charset=\"utf-8\" /></head>"]
15+
},
16+
17+
{"description": "head w/title",
18+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
19+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["StartTag", "http://www.w3.org/1999/xhtml","title",{}], ["Characters", "foo"],["EndTag", "http://www.w3.org/1999/xhtml", "title"], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
20+
"expected": ["<meta charset=utf-8><title>foo</title>"],
21+
"xhtml": ["<head><meta charset=\"utf-8\" /><title>foo</title></head>"]
22+
},
23+
24+
{"description": "head w/meta-charset",
25+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
26+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "charset", "value": "ascii"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
27+
"expected": ["<meta charset=utf-8>"],
28+
"xhtml": ["<head><meta charset=\"utf-8\" /></head>"]
29+
},
30+
31+
{"description": "head w/ two meta-charset",
32+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
33+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "charset", "value": "ascii"}]], ["EmptyTag","meta",[{"namespace": null, "name": "charset", "value": "ascii"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
34+
"expected": ["<meta charset=utf-8><meta charset=utf-8>", "<head><meta charset=utf-8><meta charset=ascii>"],
35+
"xhtml": ["<head><meta charset=\"utf-8\" /><meta charset=\"utf-8\" /></head>", "<head><meta charset=\"utf-8\" /><meta charset=\"ascii\" /></head>"]
36+
},
37+
38+
{"description": "head w/robots",
39+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
40+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "name", "value": "robots"},{"namespace": null, "name": "content", "value": "noindex"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
41+
"expected": ["<meta charset=utf-8><meta content=noindex name=robots>"],
42+
"xhtml": ["<head><meta charset=\"utf-8\" /><meta content=\"noindex\" name=\"robots\" /></head>"]
43+
},
44+
45+
{"description": "head w/robots & charset",
46+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
47+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "name", "value": "robots"},{"namespace": null, "name": "content", "value": "noindex"}]], ["EmptyTag","meta",[{"namespace": null, "name": "charset", "value": "ascii"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
48+
"expected": ["<meta content=noindex name=robots><meta charset=utf-8>"],
49+
"xhtml": ["<head><meta content=\"noindex\" name=\"robots\" /><meta charset=\"utf-8\" /></head>"]
50+
},
51+
52+
{"description": "head w/ charset in http-equiv content-type",
53+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
54+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "http-equiv", "value": "content-type"}, {"namespace": null, "name": "content", "value": "text/html; charset=ascii"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
55+
"expected": ["<meta content=\"text/html; charset=utf-8\" http-equiv=content-type>"],
56+
"xhtml": ["<head><meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\" /></head>"]
57+
},
58+
59+
{"description": "head w/robots & charset in http-equiv content-type",
60+
"options": {"inject_meta_charset": true, "encoding":"utf-8"},
61+
"input": [["StartTag", "http://www.w3.org/1999/xhtml", "head", {}], ["EmptyTag","meta",[{"namespace": null, "name": "name", "value": "robots"},{"namespace": null, "name": "content", "value": "noindex"}]], ["EmptyTag","meta",[{"namespace": null, "name": "http-equiv", "value": "content-type"}, {"namespace": null, "name": "content", "value": "text/html; charset=ascii"}]], ["EndTag", "http://www.w3.org/1999/xhtml", "head"]],
62+
"expected": ["<meta content=noindex name=robots><meta content=\"text/html; charset=utf-8\" http-equiv=content-type>"],
63+
"xhtml": ["<head><meta content=\"noindex\" name=\"robots\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\" /></head>"]
64+
}
65+
66+
]}

0 commit comments

Comments
 (0)