michael@0: Tree Construction Tests michael@0: ======================= michael@0: michael@0: Each file containing tree construction tests consists of any number of michael@0: tests separated by two newlines (LF) and a single newline before the end michael@0: of the file. For instance: michael@0: michael@0: [TEST]LF michael@0: LF michael@0: [TEST]LF michael@0: LF michael@0: [TEST]LF michael@0: michael@0: Where [TEST] is the following format: michael@0: michael@0: Each test must begin with a string "\#data" followed by a newline (LF). michael@0: All subsequent lines until a line that says "\#errors" are the test data michael@0: and must be passed to the system being tested unchanged, except with the michael@0: final newline (on the last line) removed. michael@0: michael@0: Then there must be a line that says "\#errors". It must be followed by michael@0: one line per parse error that a conformant checker would return. It michael@0: doesn't matter what those lines are, although they can't be michael@0: "\#document-fragment", "\#document", or empty, the only thing that michael@0: matters is that there be the right number of parse errors. michael@0: michael@0: Then there \*may\* be a line that says "\#document-fragment", which must michael@0: be followed by a newline (LF), followed by a string of characters that michael@0: indicates the context element, followed by a newline (LF). If this line michael@0: is present the "\#data" must be parsed using the HTML fragment parsing michael@0: algorithm with the context element as context. michael@0: michael@0: Then there must be a line that says "\#document", which must be followed michael@0: by a dump of the tree of the parsed DOM. Each node must be represented michael@0: by a single line. Each line must start with "| ", followed by two spaces michael@0: per parent node that the node has before the root document node. michael@0: michael@0: - Element nodes must be represented by a "`<`" then the *tag name michael@0: string* "`>`", and all the attributes must be given, sorted michael@0: lexicographically by UTF-16 code unit according to their *attribute michael@0: name string*, on subsequent lines, as if they were children of the michael@0: element node. michael@0: - Attribute nodes must have the *attribute name string*, then an "=" michael@0: sign, then the attribute value in double quotes ("). michael@0: - Text nodes must be the string, in double quotes. Newlines aren't michael@0: escaped. michael@0: - Comments must be "`<`" then "`!-- `" then the data then "` -->`". michael@0: - DOCTYPEs must be "``". michael@0: - Processing instructions must be "``". (The HTML parser cannot emit michael@0: processing instructions, but scripts can, and the WebVTT to DOM michael@0: rules can emit them.) michael@0: michael@0: The *tag name string* is the local name prefixed by a namespace michael@0: designator. For the HTML namespace, the namespace designator is the michael@0: empty string, i.e. there's no prefix. For the SVG namespace, the michael@0: namespace designator is "svg ". For the MathML namespace, the namespace michael@0: designator is "math ". michael@0: michael@0: The *attribute name string* is the local name prefixed by a namespace michael@0: designator. For no namespace, the namespace designator is the empty michael@0: string, i.e. there's no prefix. For the XLink namespace, the namespace michael@0: designator is "xlink ". For the XML namespace, the namespace designator michael@0: is "xml ". For the XMLNS namespace, the namespace designator is "xmlns michael@0: ". Note the difference between "xlink:href" which is an attribute in no michael@0: namespace with the local name "xlink:href" and "xlink href" which is an michael@0: attribute in the xlink namespace with the local name "href". michael@0: michael@0: If there is also a "\#document-fragment" the bit following "\#document" michael@0: must be a representation of the HTML fragment serialization for the michael@0: context element given by "\#document-fragment". michael@0: michael@0: For example: michael@0: michael@0: #data michael@0:

One

Two michael@0: #errors michael@0: 3: Missing document type declaration michael@0: #document michael@0: | michael@0: | michael@0: | michael@0: |

michael@0: | "One" michael@0: |

michael@0: | "Two"