]> git.proxmox.com Git - rustc.git/blame - src/vendor/html5ever/html5lib-tests/tree-construction/README.md
New upstream version 1.28.0+dfsg1
[rustc.git] / src / vendor / html5ever / html5lib-tests / tree-construction / README.md
CommitLineData
83c7162d
XL
1Tree Construction Tests
2=======================
3
4Each file containing tree construction tests consists of any number of
5tests separated by two newlines (LF) and a single newline before the end
6of the file. For instance:
7
8 [TEST]LF
9 LF
10 [TEST]LF
11 LF
12 [TEST]LF
13
14Where [TEST] is the following format:
15
16Each test must begin with a string "\#data" followed by a newline (LF).
17All subsequent lines until a line that says "\#errors" are the test data
18and must be passed to the system being tested unchanged, except with the
19final newline (on the last line) removed.
20
21Then there must be a line that says "\#errors". It must be followed by
22one line per parse error that a conformant checker would return. It
23doesn't matter what those lines are, although they can't be
24"\#document-fragment", "\#document", "\#script-off", "\#script-on", or
25empty, the only thing that matters is that there be the right number
26of parse errors.
27
28Then there \*may\* be a line that says "\#document-fragment", which must
29be followed by a newline (LF), followed by a string of characters that
30indicates the context element, followed by a newline (LF). If the string
31of characters starts with "svg ", the context element is in the SVG
32namespace and the substring after "svg " is the local name. If the
33string of characters starts with "math ", the context element is in the
34MathML namespace and the substring after "math " is the local name.
35Otherwise, the context element is in the HTML namespace and the string
36is the local name. If this line is present the "\#data" must be parsed
37using the HTML fragment parsing algorithm with the context element as
38context.
39
40Then there \*may\* be a line that says "\#script-off" or
41"\#script-on". If a line that says "\#script-off" is present, the
42parser must set the scripting flag to disabled. If a line that says
43"\#script-on" is present, it must set it to enabled. Otherwise, the
44test should be run in both modes.
45
46Then there must be a line that says "\#document", which must be followed
47by a dump of the tree of the parsed DOM. Each node must be represented
48by a single line. Each line must start with "| ", followed by two spaces
49per parent node that the node has before the root document node.
50
51- Element nodes must be represented by a "`<`" then the *tag name
52 string* "`>`", and all the attributes must be given, sorted
53 lexicographically by UTF-16 code unit according to their *attribute
54 name string*, on subsequent lines, as if they were children of the
55 element node.
56- Attribute nodes must have the *attribute name string*, then an "="
57 sign, then the attribute value in double quotes (").
58- Text nodes must be the string, in double quotes. Newlines aren't
59 escaped.
60- Comments must be "`<`" then "`!-- `" then the data then "` -->`".
61- DOCTYPEs must be "`<!DOCTYPE `" then the name then if either of the
62 system id or public id is non-empty a space, public id in
63 double-quotes, another space an the system id in double-quotes, and
64 then in any case "`>`".
65- Processing instructions must be "`<?`", then the target, then a
66 space, then the data and then "`>`". (The HTML parser cannot emit
67 processing instructions, but scripts can, and the WebVTT to DOM
68 rules can emit them.)
69- Template contents are represented by the string "content" with the
70 children below it.
71
72The *tag name string* is the local name prefixed by a namespace
73designator. For the HTML namespace, the namespace designator is the
74empty string, i.e. there's no prefix. For the SVG namespace, the
75namespace designator is "svg ". For the MathML namespace, the namespace
76designator is "math ".
77
78The *attribute name string* is the local name prefixed by a namespace
79designator. For no namespace, the namespace designator is the empty
80string, i.e. there's no prefix. For the XLink namespace, the namespace
81designator is "xlink ". For the XML namespace, the namespace designator
82is "xml ". For the XMLNS namespace, the namespace designator is "xmlns
83". Note the difference between "xlink:href" which is an attribute in no
84namespace with the local name "xlink:href" and "xlink href" which is an
85attribute in the xlink namespace with the local name "href".
86
87If there is also a "\#document-fragment" the bit following "\#document"
88must be a representation of the HTML fragment serialization for the
89context element given by "\#document-fragment".
90
91For example:
92
93 #data
94 <p>One<p>Two
95 #errors
96 3: Missing document type declaration
97 #document
98 | <html>
99 | <head>
100 | <body>
101 | <p>
102 | "One"
103 | <p>
104 | "Two"