parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +Tree Construction Tests
     1.5 +=======================
     1.6 +
     1.7 +Each file containing tree construction tests consists of any number of
     1.8 +tests separated by two newlines (LF) and a single newline before the end
     1.9 +of the file. For instance:
    1.10 +
    1.11 +    [TEST]LF
    1.12 +    LF
    1.13 +    [TEST]LF
    1.14 +    LF
    1.15 +    [TEST]LF
    1.16 +
    1.17 +Where [TEST] is the following format:
    1.18 +
    1.19 +Each test must begin with a string "\#data" followed by a newline (LF).
    1.20 +All subsequent lines until a line that says "\#errors" are the test data
    1.21 +and must be passed to the system being tested unchanged, except with the
    1.22 +final newline (on the last line) removed.
    1.23 +
    1.24 +Then there must be a line that says "\#errors". It must be followed by
    1.25 +one line per parse error that a conformant checker would return. It
    1.26 +doesn't matter what those lines are, although they can't be
    1.27 +"\#document-fragment", "\#document", or empty, the only thing that
    1.28 +matters is that there be the right number of parse errors.
    1.29 +
    1.30 +Then there \*may\* be a line that says "\#document-fragment", which must
    1.31 +be followed by a newline (LF), followed by a string of characters that
    1.32 +indicates the context element, followed by a newline (LF). If this line
    1.33 +is present the "\#data" must be parsed using the HTML fragment parsing
    1.34 +algorithm with the context element as context.
    1.35 +
    1.36 +Then there must be a line that says "\#document", which must be followed
    1.37 +by a dump of the tree of the parsed DOM. Each node must be represented
    1.38 +by a single line. Each line must start with "| ", followed by two spaces
    1.39 +per parent node that the node has before the root document node.
    1.40 +
    1.41 +-   Element nodes must be represented by a "`<`" then the *tag name
    1.42 +    string* "`>`", and all the attributes must be given, sorted
    1.43 +    lexicographically by UTF-16 code unit according to their *attribute
    1.44 +    name string*, on subsequent lines, as if they were children of the
    1.45 +    element node.
    1.46 +-   Attribute nodes must have the *attribute name string*, then an "="
    1.47 +    sign, then the attribute value in double quotes (").
    1.48 +-   Text nodes must be the string, in double quotes. Newlines aren't
    1.49 +    escaped.
    1.50 +-   Comments must be "`<`" then "`!-- `" then the data then "` -->`".
    1.51 +-   DOCTYPEs must be "`<!DOCTYPE `" then the name then if either of the
    1.52 +    system id or public id is non-empty a space, public id in
    1.53 +    double-quotes, another space an the system id in double-quotes, and
    1.54 +    then in any case "`>`".
    1.55 +-   Processing instructions must be "`<?`", then the target, then a
    1.56 +    space, then the data and then "`>`". (The HTML parser cannot emit
    1.57 +    processing instructions, but scripts can, and the WebVTT to DOM
    1.58 +    rules can emit them.)
    1.59 +
    1.60 +The *tag name string* is the local name prefixed by a namespace
    1.61 +designator. For the HTML namespace, the namespace designator is the
    1.62 +empty string, i.e. there's no prefix. For the SVG namespace, the
    1.63 +namespace designator is "svg ". For the MathML namespace, the namespace
    1.64 +designator is "math ".
    1.65 +
    1.66 +The *attribute name string* is the local name prefixed by a namespace
    1.67 +designator. For no namespace, the namespace designator is the empty
    1.68 +string, i.e. there's no prefix. For the XLink namespace, the namespace
    1.69 +designator is "xlink ". For the XML namespace, the namespace designator
    1.70 +is "xml ". For the XMLNS namespace, the namespace designator is "xmlns
    1.71 +". Note the difference between "xlink:href" which is an attribute in no
    1.72 +namespace with the local name "xlink:href" and "xlink href" which is an
    1.73 +attribute in the xlink namespace with the local name "href".
    1.74 +
    1.75 +If there is also a "\#document-fragment" the bit following "\#document"
    1.76 +must be a representation of the HTML fragment serialization for the
    1.77 +context element given by "\#document-fragment".
    1.78 +
    1.79 +For example:
    1.80 +
    1.81 +    #data
    1.82 +    <p>One<p>Two
    1.83 +    #errors
    1.84 +    3: Missing document type declaration
    1.85 +    #document
    1.86 +    | <html>
    1.87 +    |   <head>
    1.88 +    |   <body>
    1.89 +    |     <p>
    1.90 +    |       "One"
    1.91 +    |     <p>
    1.92 +    |       "Two"

mercurial