summaryrefslogtreecommitdiffstats
path: root/dom/base/test/unit/test_delete_range.xml
blob: c8d50bd32a81763d76eb8a1bc5a502ec390f5324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file holds serialized tests for DOM Range tests on extractContents.
The <test/> elements designate individual tests.  Each one has the following:

* A <source/> element, designating the start conditions of the test,
* A <result/> element, designating what the source element should look like
  after the extraction,
* An <extract/> element, designating what the extracted content should look like.

The <split/> element designates a split between two DOM nodes. This element will
be removed before the actual test, and the two nodes on either side will not be
merged.

The <empty-cdata/> element designates an empty character data section.  Before
the test executes, this element is replaced with an actual CDATASection node.

For the <source/> element, there are four attributes:

* startContainer:  A XPath to the startContainer of the range.
* endContainer:  A XPath to the endContainer of the range.
* startOffset:  The startOffset of the range.
* endOffset:  The endOffset of the range.

Note this test may need updating with a fix for bug 401276.  The spec states
adjacent nodes after an extraction should be merged if possible, but using the
normalize() method, which could have unintended side effects... For now, we're
not permitting that, pending clarification.

Please make sure the first test in this document always tests a range where the
start container and end container are the same text node, and where the start
offset and end offsets are valid and inequal.  Some of the additional range
tests (after the bulk of the delete/extract tests) depend on it.
  -->
<root>
  <!-- Extracting from a text node. -->
  <test>
    <source startContainer="text()[1]"
            endContainer="text()[1]"
            startOffset="4"
            endOffset="10">The quick fox</source>
    <result>The fox</result>
    <extract>quick </extract>
  </test>

  <!-- Extracting from a CDATA section. -->
  <test>
    <source startContainer="text()[1]"
            endContainer="text()[1]"
            startOffset="4"
            endOffset="10"><![CDATA[The quick fox]]></source>
    <result><![CDATA[The fox]]></result>
    <extract><![CDATA[quick ]]></extract>
  </test>

  <!-- Snipping the start of a text node. -->
  <test>
    <source startContainer="text()[1]"
            endContainer="text()[1]"
            startOffset="0"
            endOffset="4"><![CDATA[The quick fox]]></source>
    <result><![CDATA[quick fox]]></result>
    <extract><![CDATA[The ]]></extract>
  </test>

  <!-- Extracting from a comment. -->
  <test>
    <source startContainer="comment()[1]"
            endContainer="comment()[1]"
            startOffset="4"
            endOffset="10"><!--The quick fox--></source>
    <result><!--The fox--></result>
    <extract><!--quick --></extract>
  </test>

  <!-- Snipping whole nodes -->
  <test>
    <source startContainer="."
            endContainer="."
            startOffset="0"
            endOffset="2">Fox<fox/>Fox<bear/><!--comment--></source>
    <result>Fox<bear/><!--comment--></result>
    <extract>Fox<fox/></extract>
  </test>

  <!-- Snipping whole nodes -->
  <test>
    <source startContainer="."
            endContainer="."
            startOffset="1"
            endOffset="3">Fox<fox/>Fox<bear/><!--comment--></source>
    <result>Fox<bear/><!--comment--></result>
    <extract><fox/>Fox</extract>
  </test>

  <!-- Snipping a mixture of nodes and portions of text -->
  <test>
    <source startContainer="text()[2]"
            startOffset="1"
            endContainer="comment()[1]"
            endOffset="3">Fox<fox/>Fox<bear><?cow ?></bear><!--comment--></source>
    <result>Fox<fox/>F<!--ment--></result>
    <extract>ox<bear><?cow ?></bear><!--com--></extract>
  </test>

  <!-- Extracting with a collapsed range from a text node. -->
  <test>
    <source startContainer="text()[1]"
            endContainer="text()[1]"
            startOffset="4"
            endOffset="4">The quick fox</source>
    <result>The quick fox</result>
    <extract/>
  </test>

  <!-- Extracting with a collapsed range from a non-text node. -->
  <test>
    <source startContainer="."
            endContainer="."
            startOffset="0"
            endOffset="0">Fox<fox/>Fox<bear/><!--comment--></source>
    <result>Fox<fox/>Fox<bear/><!--comment--></result>
    <extract/>
  </test>
</root>