• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[
2    {
3        "name": "Template content",
4        "input": "<body><template>Some <div>content</div></template></body>",
5        "expected": "<html><head></head><body><template>Some <div>content</div></template></body></html>"
6    },
7    {
8        "name": "Attributes",
9        "input": "<head><meta http-equiv=\"refresh\" content=\"30\"></head><body><div style=\"background-color:red; padding: 0 25px 32px;\"></body>",
10        "expected": "<html><head><meta http-equiv=\"refresh\" content=\"30\"></head><body><div style=\"background-color:red; padding: 0 25px 32px;\"></div></body></html>"
11    },
12    {
13        "name": "Attribute serialized name - XML namespace",
14        "input": "<svg xml:base=\"http://example.org\"></svg>",
15        "expected": "<html><head></head><body><svg xml:base=\"http://example.org\"></svg></body></html>"
16    },
17    {
18        "name": "Attribute serialized name - XMLNS namespace",
19        "input": "<svg xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"></svg",
20        "expected": "<html><head></head><body><svg xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"></svg></body></html>"
21    },
22    {
23        "name": "Attribute serialized name - XLink namespace",
24        "input": "<svg xlink:title=\"Hey!\"></svg>",
25        "expected": "<html><head></head><body><svg xlink:title=\"Hey!\"></svg></body></html>"
26    },
27    {
28        "name": "Attribute value escaping - &amp;",
29        "input": "<div data-foo=\"& 42 &\"></div>",
30        "expected": "<html><head></head><body><div data-foo=\"&amp; 42 &amp;\"></div></body></html>"
31    },
32    {
33        "name": "Attribute value escaping - &nbsp;",
34        "input": "<div data-foo=\"\u00A0 bar\u00A0\"></div>",
35        "expected": "<html><head></head><body><div data-foo=\"&nbsp; bar&nbsp;\"></div></body></html>"
36    },
37    {
38        "name": "Attribute value escaping - quotes",
39        "input": "<div data-foo=\"&quot;\" id=test1\" class='test2\"'></div>",
40        "expected": "<html><head></head><body><div data-foo=\"&quot;\" id=\"test1&quot;\" class=\"test2&quot;\"></div></body></html>"
41    },
42    {
43        "name": "Attribute value escaping - < and >",
44        "input": "<div data-foo=\"<span>\"></div>",
45        "expected": "<html><head></head><body><div data-foo=\"<span>\"></div></body></html>"
46    },
47    {
48        "name": "Attributes value escaping - other entities",
49        "input": "<div data-foo='&raquo;&phone;'>",
50        "expected": "<html><head></head><body><div data-foo=\"»☎\"></div></body></html>"
51    },
52    {
53        "name": "Void elements",
54        "input": "<area><base><basefont><bgsound><br><embed><hr><img><input><keygen><link><meta><param><source><track><wbr>",
55        "expected": "<html><head></head><body><area><base><basefont><bgsound><br><embed><hr><img><input><keygen><link><meta><param><source><track><wbr></body></html>"
56    },
57    {
58        "name": "Void elements - <col>",
59        "input": "<table><col></table>",
60        "expected": "<html><head></head><body><table><colgroup><col></colgroup></table></body></html>"
61    },
62    {
63        "name": "Void elements - <frame>",
64        "input": "<frameset><frame></frameset>",
65        "expected": "<html><head></head><frameset><frame></frameset></html>"
66    },
67    {
68        "name": "Text nodes",
69        "input": "<title>foo</title><body>foo<div>bar</div>baz</body>",
70        "expected": "<html><head><title>foo</title></head><body>foo<div>bar</div>baz</body></html>"
71    },
72    {
73        "name": "Text nodes escaping - &amp;",
74        "input": "<title>Mac&Cheese</title><div>&&&</div>",
75        "expected": "<html><head><title>Mac&amp;Cheese</title></head><body><div>&amp;&amp;&amp;</div></body></html>"
76    },
77    {
78        "name": "Text nodes escaping - &nbsp;",
79        "input": "<title>\u00A0foo\u00A0bar\u00A0</title><div>\u00A0baz\u00A0</div>",
80        "expected": "<html><head><title>&nbsp;foo&nbsp;bar&nbsp;</title></head><body><div>&nbsp;baz&nbsp;</div></body></html>"
81    },
82    {
83        "name": "Text nodes escaping - < and >",
84        "input": "<title>< foo ></title><div>> bar <</div>",
85        "expected": "<html><head><title>&lt; foo &gt;</title></head><body><div>&gt; bar &lt;</div></body></html>"
86    },
87    {
88        "name": "Text nodes escaping - quotes",
89        "input": "<title>\"foo\"</title><div>\"bar\"</div>",
90        "expected": "<html><head><title>\"foo\"</title></head><body><div>\"bar\"</div></body></html>"
91    },
92    {
93        "name": "Text nodes escaping - non-escapable tags",
94        "input": "<body><style>&\u00A0><</style><script>&\u00A0><</script><xmp>&\u00A0><</xmp><iframe>&\u00A0><</iframe><noembed>&\u00A0><</noembed><noframes>&\u00A0><</noframes><plaintext>&\u00A0><",
95        "expected": "<html><head></head><body><style>&\u00A0><</style><script>&\u00A0><</script><xmp>&\u00A0><</xmp><iframe>&\u00A0><</iframe><noembed>&\u00A0><</noembed><noframes>&\u00A0><</noframes><plaintext>&\u00A0><</plaintext></body></html>"
96    },
97    {
98        "name": "Text nodes escaping - <noscript> with scripting enabled",
99        "input": "<body><noscript>& ><</noscript></body>",
100        "expected": "<html><head></head><body><noscript>& ><</noscript></body></html>"
101    },
102    {
103        "name": "Text nodes escaping - <noscript> with scripting disabled (GH-332)",
104        "options": { "scriptingEnabled": false },
105        "input": "<body><noscript>& ><</noscript></body>",
106        "expected": "<html><head></head><body><noscript>&amp; &gt;&lt;</noscript></body></html>"
107    },
108    {
109        "name": "Comment nodes",
110        "input": "<!-- Hey --><html><head></head><!-- &\u00A0>< --><body><!-- 42 --></body></html>",
111        "expected": "<!-- Hey --><html><head></head><!-- &\u00A0>< --><body><!-- 42 --></body></html>"
112    },
113    {
114        "name": "Doctype without systemId and publicId",
115        "input": "<!DOCTYPE html>",
116        "expected": "<!DOCTYPE html><html><head></head><body></body></html>"
117    },
118    {
119        "name": "Doctype with publicId",
120        "input": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">",
121        "expected": "<!DOCTYPE html><html><head></head><body></body></html>"
122    },
123    {
124        "name": "Doctype with systemId",
125        "input": "<!DOCTYPE html SYSTEM \"http://www.w3.org/DTD/HTML4-strict.dtd\"",
126        "expected": "<!DOCTYPE html><html><head></head><body></body></html>"
127    },
128    {
129        "name": "Doctype with publicId and systemId",
130        "input": "<!DOCTYPE html html \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"",
131        "expected": "<!DOCTYPE html><html><head></head><body></body></html>"
132    },
133    {
134        "name": "Child nodes",
135        "input": "<span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span>",
136        "expected": "<html><head></head><body><span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span></body></html>"
137    },
138    {
139        "name": "<pre>, <textarea>, <listing> with initial LF (see: https://github.com/whatwg/html/pull/1815)",
140        "input": "<pre>\n1</pre><pre>\n\n2</pre><textarea>\n3</textarea><textarea>\n\n4</textarea><listing>\n5</listing><listing>\n\n6</listing>",
141        "expected": "<html><head></head><body><pre>1</pre><pre>\n2</pre><textarea>3</textarea><textarea>\n4</textarea><listing>5</listing><listing>\n6</listing></body></html>"
142    },
143    {
144        "name": "Mixed content (GH-333)",
145        "input": "<svg><style>&lt;</style></svg><style>&lt;</style><svg><script>&lt;</script></svg><script>&lt;</script>",
146        "expected": "<html><head></head><body><svg><style>&lt;</style></svg><style>&lt;</style><svg><script>&lt;</script></svg><script>&lt;</script></body></html>"
147    }
148]
149