content/test/unit/test_delete_range.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/test/unit/test_delete_range.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,125 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!--
     1.6 +This file holds serialized tests for DOM Range tests on extractContents.
     1.7 +The <test/> elements designate individual tests.  Each one has the following:
     1.8 +
     1.9 +* A <source/> element, designating the start conditions of the test,
    1.10 +* A <result/> element, designating what the source element should look like
    1.11 +  after the extraction,
    1.12 +* An <extract/> element, designating what the extracted content should look like.
    1.13 +
    1.14 +The <split/> element designates a split between two DOM nodes. This element will
    1.15 +be removed before the actual test, and the two nodes on either side will not be
    1.16 +merged.
    1.17 +
    1.18 +The <empty-cdata/> element designates an empty character data section.  Before
    1.19 +the test executes, this element is replaced with an actual CDATASection node.
    1.20 +
    1.21 +For the <source/> element, there are four attributes:
    1.22 +
    1.23 +* startContainer:  A XPath to the startContainer of the range.
    1.24 +* endContainer:  A XPath to the endContainer of the range.
    1.25 +* startOffset:  The startOffset of the range.
    1.26 +* endOffset:  The endOffset of the range.
    1.27 +
    1.28 +Note this test may need updating with a fix for bug 401276.  The spec states
    1.29 +adjacent nodes after an extraction should be merged if possible, but using the
    1.30 +normalize() method, which could have unintended side effects... For now, we're
    1.31 +not permitting that, pending clarification.
    1.32 +
    1.33 +Please make sure the first test in this document always tests a range where the
    1.34 +start container and end container are the same text node, and where the start
    1.35 +offset and end offsets are valid and inequal.  Some of the additional range
    1.36 +tests (after the bulk of the delete/extract tests) depend on it.
    1.37 +  -->
    1.38 +<root>
    1.39 +  <!-- Extracting from a text node. -->
    1.40 +  <test>
    1.41 +    <source startContainer="text()[1]"
    1.42 +            endContainer="text()[1]"
    1.43 +            startOffset="4"
    1.44 +            endOffset="10">The quick fox</source>
    1.45 +    <result>The fox</result>
    1.46 +    <extract>quick </extract>
    1.47 +  </test>
    1.48 +
    1.49 +  <!-- Extracting from a CDATA section. -->
    1.50 +  <test>
    1.51 +    <source startContainer="text()[1]"
    1.52 +            endContainer="text()[1]"
    1.53 +            startOffset="4"
    1.54 +            endOffset="10"><![CDATA[The quick fox]]></source>
    1.55 +    <result><![CDATA[The fox]]></result>
    1.56 +    <extract><![CDATA[quick ]]></extract>
    1.57 +  </test>
    1.58 +
    1.59 +  <!-- Snipping the start of a text node. -->
    1.60 +  <test>
    1.61 +    <source startContainer="text()[1]"
    1.62 +            endContainer="text()[1]"
    1.63 +            startOffset="0"
    1.64 +            endOffset="4"><![CDATA[The quick fox]]></source>
    1.65 +    <result><![CDATA[quick fox]]></result>
    1.66 +    <extract><![CDATA[The ]]></extract>
    1.67 +  </test>
    1.68 +
    1.69 +  <!-- Extracting from a comment. -->
    1.70 +  <test>
    1.71 +    <source startContainer="comment()[1]"
    1.72 +            endContainer="comment()[1]"
    1.73 +            startOffset="4"
    1.74 +            endOffset="10"><!--The quick fox--></source>
    1.75 +    <result><!--The fox--></result>
    1.76 +    <extract><!--quick --></extract>
    1.77 +  </test>
    1.78 +
    1.79 +  <!-- Snipping whole nodes -->
    1.80 +  <test>
    1.81 +    <source startContainer="."
    1.82 +            endContainer="."
    1.83 +            startOffset="0"
    1.84 +            endOffset="2">Fox<fox/>Fox<bear/><!--comment--></source>
    1.85 +    <result>Fox<bear/><!--comment--></result>
    1.86 +    <extract>Fox<fox/></extract>
    1.87 +  </test>
    1.88 +
    1.89 +  <!-- Snipping whole nodes -->
    1.90 +  <test>
    1.91 +    <source startContainer="."
    1.92 +            endContainer="."
    1.93 +            startOffset="1"
    1.94 +            endOffset="3">Fox<fox/>Fox<bear/><!--comment--></source>
    1.95 +    <result>Fox<bear/><!--comment--></result>
    1.96 +    <extract><fox/>Fox</extract>
    1.97 +  </test>
    1.98 +
    1.99 +  <!-- Snipping a mixture of nodes and portions of text -->
   1.100 +  <test>
   1.101 +    <source startContainer="text()[2]"
   1.102 +            startOffset="1"
   1.103 +            endContainer="comment()[1]"
   1.104 +            endOffset="3">Fox<fox/>Fox<bear><?cow ?></bear><!--comment--></source>
   1.105 +    <result>Fox<fox/>F<!--ment--></result>
   1.106 +    <extract>ox<bear><?cow ?></bear><!--com--></extract>
   1.107 +  </test>
   1.108 +
   1.109 +  <!-- Extracting with a collapsed range from a text node. -->
   1.110 +  <test>
   1.111 +    <source startContainer="text()[1]"
   1.112 +            endContainer="text()[1]"
   1.113 +            startOffset="4"
   1.114 +            endOffset="4">The quick fox</source>
   1.115 +    <result>The quick fox</result>
   1.116 +    <extract/>
   1.117 +  </test>
   1.118 +
   1.119 +  <!-- Extracting with a collapsed range from a non-text node. -->
   1.120 +  <test>
   1.121 +    <source startContainer="."
   1.122 +            endContainer="."
   1.123 +            startOffset="0"
   1.124 +            endOffset="0">Fox<fox/>Fox<bear/><!--comment--></source>
   1.125 +    <result>Fox<fox/>Fox<bear/><!--comment--></result>
   1.126 +    <extract/>
   1.127 +  </test>
   1.128 +</root>

mercurial